diff --git a/manual/luatex-backend.tex b/manual/luatex-backend.tex
index e24f741c18981703856b043c9c461b76a62c5e06..ed9edeea75d0647328ab525f988466c299b58471 100644
--- a/manual/luatex-backend.tex
+++ b/manual/luatex-backend.tex
@@ -112,6 +112,11 @@ pdf.setorigin(tex.sp("1in"),tex.sp("1in"))
 
 The counterpart of this function returns two values.
 
+\subsection{\type {[set|get]imageresolution}}
+
+These two functions relate to the imageresolution that is used when the image
+itself doesn't provide a non|-|zero x or y resolution.
+
 \subsection {\type {[set|get][link|dest|thread|xform]margin}}
 
 These functions can be used to set and retrieve the margins that are added to the
@@ -297,6 +302,15 @@ are the same as for the similar backend extension primitive.
 pdf.newcolorstack("0 g","page",true) -- page|direct|origin
 \stopfunctioncall
 
+\subsection {\type {setfontattributes}}
+
+This function will force some additional code into the font resource. It can for
+instance be used to add a custom \type {ToUnicode} vector to a bitmap file.
+
+\startfunctioncall
+pdf.setfontattributes(<number> font id, <string> pdf code)
+\stopfunctioncall
+
 \section {The \type {pdfscanner} library}
 
 The \type {pdfscanner} library allows interpretation of \PDF\ content streams and
diff --git a/manual/luatex-enhancements.tex b/manual/luatex-enhancements.tex
index 96774815dc7cb02779835688b9f53631054bc612..d55eef2860e4d466b4ed00f7d377f01e3270d383 100644
--- a/manual/luatex-enhancements.tex
+++ b/manual/luatex-enhancements.tex
@@ -801,6 +801,12 @@ optional parameters are not implemented for \type {\saveboxresource}.
 \useboxresource   width 20mm height 10mm depth 5mm \lastsavedboxresourceindex
 \stoptyping
 
+The box resources are of course implemented in the backend and therefore we do
+support the \type {attr} and \type {resources} keys that accept a token list. New
+is the \type {type} key. When set to non|-|zero the \type {/Type} entry is
+omitted. A value of 1 or 3 still writes a \type {/BBox}, while 2 or 3 will write
+a \type {/Matrix}.
+
 \subsection{\type {\nohrule} and \type {\novrule}}
 
 Because introducing a new keyword can cause incompatibilities, two new primitives
diff --git a/manual/luatex-fonts.tex b/manual/luatex-fonts.tex
index 7384f3b3ecca376ffd747471dbf1bd50bcef0fb8..90412ea816d23a0416c0b0669ef667fb8410111d 100644
--- a/manual/luatex-fonts.tex
+++ b/manual/luatex-fonts.tex
@@ -36,7 +36,9 @@ The top|-|level keys in the table are as follows:
 \NC fonts            \NC yes \NC no  \NC yes \NC table  \NC locally used fonts \NC \NR
 \NC psname           \NC no  \NC no  \NC yes \NC string \NC This is the \POSTSCRIPT\ fontname in the incoming font
                                                             source, and it's used as fontname identifier in the \PDF\
-                                                            output. \NC \NR
+                                                            output. This has to be a valid string, e.g.\ no spaces
+                                                            and such, as the backend will not do a cleanup. This gives
+                                                            complete control to the loader. \NC \NR
 \NC fullname         \NC no  \NC no  \NC yes \NC string \NC output font name, used as a fallback in the \PDF\ output
                                                             if the \type {psname} is not set \NC \NR
 \NC header           \NC yes \NC no  \NC no  \NC string \NC header comments, if any \NC \NR
diff --git a/manual/luatex-graphics.tex b/manual/luatex-graphics.tex
index 91feaaff8ec9e36b6b1cea6889c48fdc83081175..04a9bd50b5fd69ac18dee610569fc76441fe3f5e 100644
--- a/manual/luatex-graphics.tex
+++ b/manual/luatex-graphics.tex
@@ -316,11 +316,15 @@ of different fields, as follows:
 \NC error_line  \NC number   \NC error line width         \NC 79                \NC \NR
 \NC print_line  \NC number   \NC line length in ps output \NC 100               \NC \NR
 \NC random_seed \NC number   \NC the initial random seed  \NC variable          \NC \NR
-\NC interaction \NC string   \NC the interaction mode,
-                                 one of
+\NC math_mode   \NC string   \NC the number system to use:
+                                 \type {double},
+                                 \type {scaled},
+                                 \type {binary} or
+                                 \type {decimal}          \NC \type {scaled}    \NC \NR
+\NC interaction \NC string   \NC the interaction mode:
                                  \type {batch},
                                  \type {nonstop},
-                                 \type {scroll},
+                                 \type {scroll} or
                                  \type {errorstop}        \NC \type {errorstop} \NC \NR
 \NC job_name    \NC string   \NC \type {--jobname}        \NC \type {mpout}     \NC \NR
 \NC find_file   \NC function \NC a function to find files \NC only local files  \NC \NR
diff --git a/manual/luatex-languages.tex b/manual/luatex-languages.tex
index 83969acef71a02e6c26e905c69709b863b6fcd2c..ad7b7b9d686e4ac11b7c2600a5cd137e5924aa47 100644
--- a/manual/luatex-languages.tex
+++ b/manual/luatex-languages.tex
@@ -212,6 +212,25 @@ as trigger. Here are a few examples of usage:
 \stopbuffer
 \typebuffer \start \dontcomplain \hsize 1pt \getbuffer \par \stop
 
+We only accept an explicit hyphen when there is a preceding glyph and we skip a
+sequence of explicit hyphens as that normally indicates a \type {--} or \type
+{---} ligature in which case we can in a worse case usage get bad node lists
+later on due to messed up ligature building as these dashes are ligatures in base
+fonts. This is a side effect of the separating the hyphenation, ligaturing and
+kerning steps.
+
+The start and end of a characters is signalled by a glue, penalty, kern or boundary
+node. But by default also a hlist, vlist, rule, dir, whatsit, ins, and adjust node
+indicate a start or end. You can omit the last set from the test by setting
+\type {\hyphenationbounds} to a non|-|zero value:
+
+\starttabulate[|Tl|l|]
+\NC 0 \NC not strict \NC \NR
+\NC 1 \NC strict start \NC \NR
+\NC 2 \NC strict end \NC \NR
+\NC 3 \NC strict start and strict end \NC \NR
+\stoptabulate
+
 \section{The main control loop}
 
 In \LUATEX's main loop, almost all input characters that are to be typeset are
@@ -735,3 +754,17 @@ initialized due to \type {\savinghyphcodes} being larger than zero.
 \stopchapter
 
 \stopcomponent
+
+% \parindent0pt \hsize=1.1cm
+% 12-34-56 \par
+% 12-34-\hbox{56} \par
+% 12-34-\vrule width 1em height 1.5ex \par
+% 12-\hbox{34}-56 \par
+% 12-\vrule width 1em height 1.5ex-56 \par
+% \hjcode`\1=`\1 \hjcode`\2=`\2 \hjcode`\3=`\3 \hjcode`\4=`\4 \vskip.5cm
+% 12-34-56 \par
+% 12-34-\hbox{56} \par
+% 12-34-\vrule width 1em height 1.5ex \par
+% 12-\hbox{34}-56 \par
+% 12-\vrule width 1em height 1.5ex-56 \par
+
diff --git a/manual/luatex-modifications.tex b/manual/luatex-modifications.tex
index e59e09e1e40eee127511b55a12d56d42c295c2cf..549cfe37772c929ab59905cd5c322c73e42f7938 100644
--- a/manual/luatex-modifications.tex
+++ b/manual/luatex-modifications.tex
@@ -524,7 +524,9 @@ different:
 
 \stopsubsection
 
-\startsubsection[reference=backendprimitives,title=The backend primitives \type {\pdf*}]
+\stopsection
+
+\startsection[reference=backendprimitives,title=The backend primitives \type {\pdf*}]
 
 In a previous section we mentioned that some \PDFTEX\ primitives were removed and
 others promoted to core \LUATEX\ primitives. That is only part of the story. In
@@ -775,7 +777,348 @@ normally generated by the engine:
 
 So, you even need to include the brackets!
 
-\stopsubsection
+Although we started from a merge of \PDFTEX\ and \ALEPH, by now the code base as
+well as functionality has diverted from those parents. Here we show the options
+that can be passed to the extensions.
+
+\starttexsyntax
+\pdfextension literal
+    [ direct | page ] { tokens }
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension dest
+    num integer | name { tokens }!crlf
+    [ fitbh | fitbv | fitb | fith| fitv | fit |
+      fitr <rule spec> | xyz [ zoom <integer> ]
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension annot
+    reserveobjnum | useobjnum <integer>
+    { tokens }
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension save
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension restore
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension setmatrix
+    { tokens }
+\stoptexsyntax
+
+\starttexsyntax
+[ \immediate ] \pdfextension obj
+    reserveobjnum
+\stoptexsyntax
+
+\starttexsyntax
+[ \immediate ] \pdfextension obj
+    [ useobjnum <integer> ]
+    [ uncompressed ]
+    [ stream  [ attr { tokens } ] ]
+    [ file ]
+    { tokens }
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension refobj
+    <integer>
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension colorstack
+    <integer>
+    set { tokens } | push { tokens } | pop | current
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension startlink
+    [ attr { tokens } ]
+    user { tokens } | goto | thread
+    [ file { tokens } ]
+    [ page <integer> { tokens } | name { tokens } | num  integer ]
+    [ newwindow  | nonewwindow ]
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension endlink
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension startthread
+    num <integer> | name { tokens }
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension endthread
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension thread
+    num <integer> | name { tokens }
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension outline
+    [ attr { tokens } ]
+    [ useobjnum <integer> ]
+    [ count <integer> ]
+    { tokens }
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension glyphtounicode
+    { tokens }
+    { tokens }
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension catalog
+    { tokens }
+    [ openaction
+      user { tokens } | goto | thread
+      [ file { tokens } ]
+      [ page <integer> { tokens } | name { tokens } | num <integer> ]
+      [ newwindow  | nonewwindow ] ]
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension fontattr
+    <integer>
+    {tokens}
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension mapfile
+    {tokens}
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension mapline
+    {tokens}
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension includechars
+    {tokens}
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension info
+    {tokens}
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension names
+    {tokens}
+\stoptexsyntax
+
+\starttexsyntax
+\pdfextension trailer
+    {tokens}
+\stoptexsyntax
+
+\stopsection
+
+\startsection[title=Directions]
+
+The directional model in \LUATEX\ is inherited from \OMEGA|/|\ALEPH\ but we tried
+to improve it a bit. At some point we played with recovery of modes but that was
+disabled later on when we found that it interfered with nested directions. That
+itself had as side effect that the node list was no longer balanced with respect
+to directional nodes which in turn can give side effects when a series of dir
+changes happens without grouping.
+
+The current (0.97 onward) approach is that we again make the list balanced but
+try to avoid some side effects. What happens is quite intuitive if we forget
+about spaces (turned into glue) but even there what happens makes sense if you
+look at it in detail. However that logic makes in|-|group switching kind of
+useless when no proper nested grouping is used: switching from right to left
+several times nested, results in spacing ending up after each other due to nested
+mirroring. Of course a sane macro package will manage this for the user but here
+we are discussing the low level dir injection.
+
+This is what happens:
+
+\starttyping
+\textdir TRT nur {\textdir TLT run \textdir TRT NUR} nur
+\stoptyping
+
+This becomes stepwise:
+
+\startnarrower
+\starttyping
+injected: [+TRT]nur {[+TLT]run [+TRT]NUR} nur
+balanced: [+TRT]nur {[+TLT]run [-TLT][+TRT]NUR[-TRT]} nur[-TRT]
+result  : run {RUNrun } run
+\stoptyping
+\stopnarrower
+
+And this:
+
+\starttyping
+\textdir TRT nur {nur \textdir TLT run \textdir TRT NUR} nur
+\stoptyping
+
+becomes:
+
+\startnarrower
+\starttyping
+injected: [+TRT]nur {nur [+TLT]run [+TRT]NUR} nur
+balanced: [+TRT]nur {nur [+TLT]run [-TLT][+TRT]NUR[-TRT]} nur[-TRT]
+result  : run {run RUNrun } run
+\stoptyping
+\stopnarrower
+
+Now, in the following examples watch where we put the braces:
+
+\startbuffer
+\textdir TRT nur {{\textdir TLT run} {\textdir TRT NUR}} nur
+\stopbuffer
+
+\typebuffer
+
+This becomes:
+
+\startnarrower
+\getbuffer
+\stopnarrower
+
+Compare this to:
+
+\startbuffer
+\textdir TRT nur {{\textdir TLT run }{\textdir TRT NUR}} nur
+\stopbuffer
+
+\typebuffer
+
+Which renders as:
+
+\startnarrower
+\getbuffer
+\stopnarrower
+
+So how do we deal with the next?
+
+\startbuffer
+\def\ltr{\textdir TLT\relax}
+\def\rtl{\textdir TRT\relax}
+
+run {\rtl nur {\ltr run \rtl NUR \ltr run \rtl NUR} nur}
+run {\ltr run {\rtl nur \ltr RUN \rtl nur \ltr RUN} run}
+\stopbuffer
+
+\typebuffer
+
+It gets typeset as:
+
+\startnarrower
+\startlines
+\getbuffer
+\stoplines
+\stopnarrower
+
+We could define the two helpers to look back, pick up a skip, remove it and
+inject it after the dir node. But that way we loose the subtype information that
+for some applications can be handy to be kept as|-|is. This is why we now have a
+variant of \type {\textdir} which injects the balanced node before the skip.
+Instead of the previous definition we can use:
+
+\startbuffer[def]
+\def\ltr{\linedir TLT\relax}
+\def\rtl{\linedir TRT\relax}
+\stopbuffer
+
+\typebuffer[def]
+
+and this time:
+
+\startbuffer[txt]
+run {\rtl nur {\ltr run \rtl NUR \ltr run \rtl NUR} nur}
+run {\ltr run {\rtl nur \ltr RUN \rtl nur \ltr RUN} run}
+\stopbuffer
+
+\typebuffer[txt]
+
+comes out as a properly spaced:
+
+\startnarrower
+\startlines
+\getbuffer[def,txt]
+\stoplines
+\stopnarrower
+
+Anything more complex that this, like combination of skips and penalties, or
+kerns, should be handled in the input or macro package because there is no way we
+can predict the expected behaviour. In fact, the \type {\linedir} is just a
+convenience extra which could also have been implemented using node list parsing.
+
+Another adaptation to the \ALEPH\ directional model is control over shapes driven
+by \type {\hangindent} and \type {\parshape}. This is controlled by a new parameter
+\type {\shapemode}:
+
+\starttabulate[|cTB|c|]
+\NC   \NC \bf \type {\hangindent} \NC \bf \type {\parshape} \NC \NR
+\NC 0 \NC  normal                 \NC normal                \NC \NR
+\NC 1 \NC  mirrored               \NC normal                \NC \NR
+\NC 2 \NC  normal                 \NC mirrored              \NC \NR
+\NC 3 \NC  mirrored               \NC mirrored              \NC \NR
+\stoptabulate
+
+The value is reset to zero (like \type {\hangindent} and \type {\parshape})
+after the paragraph is done with. You can use negative values to preven t
+this.
+
+In \in {figure} [fig:shapemode] a few examples are given.
+
+\startplacefigure[reference=fig:shapemode,title={The effect of \type {shapemode}.}]
+    \startcombination[2*3]
+        {\ruledvbox \bgroup \setuptolerance[verytolerant]
+            \hsize .45\textwidth \switchtobodyfont[6pt]
+                \pardir TLT \textdir TLT
+                \hangindent 40pt \hangafter -3
+                \leftskip10pt \input tufte \par
+         \egroup} {TLT: hangindent}
+        {\ruledvbox \bgroup \setuptolerance[verytolerant]
+            \hsize .45\textwidth \switchtobodyfont[6pt]
+            \pardir TLT \textdir TLT
+            \parshape 4 0pt .8\hsize 10pt .8\hsize 20pt .8\hsize 0pt \hsize
+            \input tufte \par
+         \egroup} {TLT: parshape}
+        {\ruledvbox \bgroup \setuptolerance[verytolerant]
+            \hsize .45\textwidth \switchtobodyfont[6pt]
+            \pardir TRT \textdir TRT
+            \hangindent 40pt \hangafter -3
+            \leftskip10pt \input tufte \par
+         \egroup} {TRT: hangindent mode 0}
+        {\ruledvbox \bgroup \setuptolerance[verytolerant]
+            \hsize .45\textwidth \switchtobodyfont[6pt]
+            \pardir TRT \textdir TRT
+            \parshape 4 0pt .8\hsize 10pt .8\hsize 20pt .8\hsize 0pt \hsize
+            \input tufte \par
+         \egroup} {TRT: parshape mode 0}
+        {\ruledvbox \bgroup \setuptolerance[verytolerant]
+            \hsize .45\textwidth \switchtobodyfont[6pt]
+            \shapemode=3
+            \pardir TRT \textdir TRT
+            \hangindent 40pt \hangafter -3
+            \leftskip10pt \input tufte \par
+         \egroup} {TRT: hangindent mode 1 & 3}
+        {\ruledvbox \bgroup \setuptolerance[verytolerant]
+            \hsize .45\textwidth \switchtobodyfont[6pt]
+            \shapemode=3
+            \pardir TRT \textdir TRT
+            \parshape 4 0pt .8\hsize 10pt .8\hsize 20pt .8\hsize 0pt \hsize
+            \input tufte \par
+         \egroup} {TRT: parshape mode 2 & 3}
+    \stopcombination
+\stopplacefigure
 
 \stopsection
 
diff --git a/manual/luatex-style.tex b/manual/luatex-style.tex
index 26688abaf26f54a60fedc8000441333c23feae22..20e19510a8db80b70e9363e246a55ac16633cf5a 100644
--- a/manual/luatex-style.tex
+++ b/manual/luatex-style.tex
@@ -1,358 +1,362 @@
-\startenvironment luatex-style
-
-% todo: use \useMPlibrary[lua]
-
-\usemodule[abr-02]
-
-\setuplayout
-  [height=middle,
-   width=middle,
-   backspace=2cm,
-   topspace=10mm,
-   bottomspace=10mm,
-   header=10mm,
-   footer=10mm,
-   footerdistance=10mm,
-   headerdistance=10mm]
-
-\setuppagenumbering
-  [alternative=doublesided]
-
-\setuptolerance
-  [stretch,tolerant]
-
-\setuptype
-  [lines=hyphenated]
-
-\setuptyping
-  [lines=hyphenated]
-
-\setupitemize
-  [each]
-  [packed]
-
-\setupwhitespace
-  [medium]
-
-\startluacode
-    local skipped = table.tohash { 'id', 'subtype', 'next', 'prev' }
-
-    function document.functions.showfields(s)
-        local t = string.split(s,',')
-        local f = node.fields(t[1],t[2])
-        if f then
-            local d = false
-            for i=1,#f do
-                local fi = f[i]
-                if skipped[fi] then
-                    -- okay
-                elseif d then
-                    context(', {\tttf %s}', fi)
-                else
-                    context('{\tttf %s}', fi)
-                    d = true
-                end
-            end
-        end
-    end
-
-    function document.functions.showid(s)
-        local t = string.split(s,',')
-        context('{tttf %s}',node.id(t[1]))
-        if t[2] then
-            context(', {tttf %s}',node.subtype(t[2]))
-        end
-    end
-
-    function document.functions.showsubtypes(s)
-        local s = node.subtypes(s)
-        local d = false
-        for k, v in table.sortedhash(s) do
-            if d then
-                context(', %s = {\\tttf %s}',k,v)
-            else
-                context('%s = {\\tttf %s}',k,v)
-                d = true
-            end
-        end
-    end
-\stopluacode
-
-\unexpanded\def\showfields  #1{\ctxlua{document.functions.showfields("#1")}}
-\unexpanded\def\showid      #1{\ctxlua{document.functions.showid("#1")}}
-\unexpanded\def\showsubtypes#1{\ctxlua{document.functions.showsubtypes("#1")}}
-
-\definecolor[blue]      [b=.5]
-\definecolor[red]       [r=.5]
-\definecolor[green]     [g=.5]
-\definecolor[maincolor] [b=.5]
-\definecolor[keptcolor] [b=.5]
-\definecolor[othercolor][r=.5,g=.5]
-
-\setupbodyfont[modern] % we need this in examples so we predefine
-
-% \doifmodeelse {atpragma} {
-%
-%   %  \setupbodyfont
-%   %    [lucidaot,10pt]
-%
-%     \setupbodyfont
-%       [dejavu,10pt]
-%
-%     \setuphead [chapter]      [style=\bfd]
-%     \setuphead [section]      [style=\bfb]
-%     \setuphead [subsection]   [style=\bfa]
-%     \setuphead [subsubsection][style=\bf]
-%
-% } {
-%
-%     \definetypeface[mainfacenormal]  [ss][sans] [iwona]       [default]
-%     \definetypeface[mainfacenormal]  [rm][serif][palatino]    [default]
-%     \definetypeface[mainfacenormal]  [tt][mono] [modern]      [default][rscale=1.1]
-%     \definetypeface[mainfacenormal]  [mm][math] [iwona]       [default]
-%
-%     \definetypeface[mainfacemedium]  [ss][sans] [iwona-medium][default]
-%     \definetypeface[mainfacemedium]  [rm][serif][palatino]    [default]
-%     \definetypeface[mainfacemedium]  [tt][mono] [modern]      [default][rscale=1.1]
-%     \definetypeface[mainfacemedium]  [mm][math] [iwona-medium][default]
-%
-%     \setupbodyfont
-%       [mainfacenormal,10pt]
-%
-%     \setuphead [chapter]      [style=\mainfacemedium\bfd]
-%     \setuphead [section]      [style=\mainfacemedium\bfb]
-%     \setuphead [subsection]   [style=\mainfacemedium\bfa]
-%     \setuphead [subsubsection][style=\mainfacemedium\bf]
-%
-% }
-
-\writestatus{luatex manual}{we assume that dejavu math is available}
-
-\setupbodyfont % assumes dejavu-math
-  [dejavu,10pt]
-
-\setuphead [chapter]      [align={flushleft,broad},style=\bfd]
-\setuphead [section]      [align={flushleft,broad},style=\bfb]
-\setuphead [subsection]   [align={flushleft,broad},style=\bfa]
-\setuphead [subsubsection][align={flushleft,broad},style=\bf]
-
-\setuphead [chapter]      [color=maincolor]
-\setuphead [section]      [color=maincolor]
-\setuphead [subsection]   [color=maincolor]
-\setuphead [subsubsection][color=maincolor]
-
-\definehead
-  [remark]
-  [subsubsubject]
-
-\setupheadertexts
-  []
-
-\definemixedcolumns
-  [twocolumns]
-  [n=2,
-   balance=yes,
-   before=\blank,
-   after=\blank]
-
-\definemixedcolumns
-  [threecolumns]
-  [twocolumns]
-  [n=3]
-
-\definemixedcolumns
-  [fourcolumns]
-  [threecolumns]
-  [n=4]
-
-% if we do this we also need to do it in table cells
-%
-% \setuptyping
-%   [color=maincolor]
-%
-% \setuptype
-%   [color=maincolor]
-
-\definetyping
-  [functioncall]
-
-\startMPdefinitions
-
-    color   luaplanetcolor ; luaplanetcolor := \MPcolor{maincolor} ;
-    color   luaholecolor   ; luaholecolor   := white ;
-    numeric luaextraangle  ; luaextraangle  := 0 ;
-    numeric luaorbitfactor ; luaorbitfactor := .25 ;
-
-    vardef lualogo = image (
-
-        % Graphic design by A. Nakonechnyj. Copyright (c) 1998, All rights reserved.
-
-        save d, r, p ; numeric d, r, p ;
-
-        d := sqrt(2)/4 ; r := 1/4 ; p := r/8 ;
-
-        fill fullcircle scaled 1
-            withcolor luaplanetcolor ;
-        draw fullcircle rotated 40.5 scaled (1+r)
-            dashed evenly scaled p
-            withpen pencircle scaled (p/2)
-            withcolor (luaorbitfactor * luaholecolor) ;
-        fill fullcircle scaled r shifted (d+1/8,d+1/8)
-            rotated - luaextraangle
-            withcolor luaplanetcolor ;
-        fill fullcircle scaled r shifted (d-1/8,d-1/8)
-            withcolor luaholecolor   ;
-        luaorbitfactor := .25 ;
-    )  enddef ;
-
-\stopMPdefinitions
-
-\startuseMPgraphic{luapage}
-    StartPage ;
-
-        fill Page withcolor \MPcolor{othercolor} ;
-
-        luaorbitfactor := 1 ;
-        picture p ; p := lualogo xsized (3PaperWidth/5) ;
-        draw p shifted center Page shifted (0,-.5ypart center ulcorner p) ;
-
-    StopPage ;
-\stopuseMPgraphic
-
-% \starttexdefinition luaextraangle
-%     % we can also just access the last page and so in mp directly
-%     \ctxlua {
-%         context(\lastpage == 0 and 0 or \realfolio*360/\lastpage)
-%     }
-% \stoptexdefinition
-
-\startuseMPgraphic{luanumber}
-  % luaextraangle  := \luaextraangle;
-    luaextraangle  := if (LastPageNumber == 0) : 0 else : (RealPageNumber / LastPageNumber) * 360  fi;
-    luaorbitfactor := 0.25 ;
-    picture p ; p := lualogo ;
-    setbounds p to boundingbox fullcircle ;
-    draw p ysized 1cm ;
-\stopuseMPgraphic
-
-\definelayer
-  [page]
-  [width=\paperwidth,
-   height=\paperheight]
-
-\setupbackgrounds
-  [leftpage]
-  [background=page]
-
-\setupbackgrounds
-  [rightpage]
-  [background=page]
-
-\startsetups pagenumber:right
-  \setlayerframed
-    [page]
-    [preset=rightbottom,offset=1cm]
-    [frame=off,height=1cm,offset=overlay]
-    {\useMPgraphic{luanumber}}
-  \setlayerframed
-    [page]
-    [preset=rightbottom,offset=1cm,x=1.5cm]
-    [frame=off,height=1cm,width=1cm,offset=overlay]
-    {\pagenumber}
-  \setlayerframed
-    [page]
-    [preset=rightbottom,offset=1cm,x=2.5cm]
-    [frame=off,height=1cm,offset=overlay]
-    {\getmarking[chapter]}
-\stopsetups
-
-\startsetups pagenumber:left
-  \setlayerframed
-    [page]
-    [preset=leftbottom,offset=1cm,x=2.5cm]
-    [frame=off,height=1cm,offset=overlay]
-    {\getmarking[chapter]}
-  \setlayerframed
-    [page]
-    [preset=leftbottom,offset=1cm,x=1.5cm]
-    [frame=off,height=1cm,width=1cm,offset=overlay]
-    {\pagenumber}
-  \setlayerframed
-    [page]
-    [preset=leftbottom,offset=1cm]
-    [frame=off,height=1cm,offset=overlay]
-    {\useMPgraphic{luanumber}}
-\stopsetups
-
-\unexpanded\def\nonterminal#1>{\mathematics{\langle\hbox{\rm #1}\rangle}}
-
-% taco's brainwave -)
-
-\newcatcodetable\syntaxcodetable
-
-\unexpanded\def\makesyntaxcodetable
-  {\begingroup
-   \catcode`\<=13 \catcode`\|=12
-   \catcode`\!= 0 \catcode`\\=12
-   \savecatcodetable\syntaxcodetable
-   \endgroup}
-
-\makesyntaxcodetable
-
-\unexpanded\def\startsyntax {\begingroup\catcodetable\syntaxcodetable  \dostartsyntax}
-\unexpanded\def\syntax      {\begingroup\catcodetable\syntaxcodetable  \dosyntax}
-           \let\stopsyntax   \relax
-
-\unexpanded\def\syntaxenvbody#1%
-  {\par
-   \tt
-   \startnarrower
-   \maincolor #1
-   \stopnarrower
-   \par}
-
-\unexpanded\def\syntaxbody#1%
-  {\begingroup
-   \maincolor \tt #1%
-   \endgroup}
-
-\bgroup \catcodetable\syntaxcodetable
-
-!gdef!dostartsyntax#1\stopsyntax{!let<!nonterminal!syntaxenvbody{#1}!endgroup}
-!gdef!dosyntax     #1{!let<!nonterminal!syntaxbody{#1}!endgroup}
-
-!egroup
-
-% end of wave
-
-\setupinteraction
-  [state=start,
-   focus=standard,
-   style=,
-   color=,
-   contrastcolor=]
-
-\placebookmarks
-  [chapter,section,subsection]
-
-\setuplist
-  [chapter,section,subsection,subsubsection]
-  [interaction=all,
-   width=3em]
-
-\setuplist
-  [chapter]
-  [style=bold,
-   color=keptcolor]
-
-\setuplist
-  [subsection,subsubsection]
-  [margin=3em,
-   width=5em]
-
-% Hans doesn't like the bookmarks opening by default so we comment this:
-%
-% \setupinteractionscreen
-%   [option=bookmark]
-
-\stopenvironment
+\startenvironment luatex-style
+
+% todo: use \useMPlibrary[lua]
+
+\usemodule[abr-02]
+
+\setuplayout
+  [height=middle,
+   width=middle,
+   backspace=2cm,
+   topspace=10mm,
+   bottomspace=10mm,
+   header=10mm,
+   footer=10mm,
+   footerdistance=10mm,
+   headerdistance=10mm]
+
+\setuppagenumbering
+  [alternative=doublesided]
+
+\setuptolerance
+  [stretch,tolerant]
+
+\setuptype
+  [lines=hyphenated]
+
+\setuptyping
+  [lines=hyphenated]
+
+\setupitemize
+  [each]
+  [packed]
+
+\setupwhitespace
+  [medium]
+
+\startluacode
+    local skipped = table.tohash { 'id', 'subtype', 'next', 'prev' }
+
+    function document.functions.showfields(s)
+        local t = string.split(s,',')
+        local f = node.fields(t[1],t[2])
+        if f then
+            local d = false
+            for i=1,#f do
+                local fi = f[i]
+                if skipped[fi] then
+                    -- okay
+                elseif d then
+                    context(', {\tttf %s}', fi)
+                else
+                    context('{\tttf %s}', fi)
+                    d = true
+                end
+            end
+        end
+    end
+
+    function document.functions.showid(s)
+        local t = string.split(s,',')
+        context('{tttf %s}',node.id(t[1]))
+        if t[2] then
+            context(', {tttf %s}',node.subtype(t[2]))
+        end
+    end
+
+    function document.functions.showsubtypes(s)
+        local s = node.subtypes(s)
+        local d = false
+        for k, v in table.sortedhash(s) do
+            if d then
+                context(', %s = {\\tttf %s}',k,v)
+            else
+                context('%s = {\\tttf %s}',k,v)
+                d = true
+            end
+        end
+    end
+\stopluacode
+
+\unexpanded\def\showfields  #1{\ctxlua{document.functions.showfields("#1")}}
+\unexpanded\def\showid      #1{\ctxlua{document.functions.showid("#1")}}
+\unexpanded\def\showsubtypes#1{\ctxlua{document.functions.showsubtypes("#1")}}
+
+\definecolor[blue]      [b=.5]
+\definecolor[red]       [r=.5]
+\definecolor[green]     [g=.5]
+\definecolor[maincolor] [b=.5]
+\definecolor[keptcolor] [b=.5]
+\definecolor[othercolor][r=.5,g=.5]
+
+\setupbodyfont[modern] % we need this in examples so we predefine
+
+% \doifmodeelse {atpragma} {
+%
+%   %  \setupbodyfont
+%   %    [lucidaot,10pt]
+%
+%     \setupbodyfont
+%       [dejavu,10pt]
+%
+%     \setuphead [chapter]      [style=\bfd]
+%     \setuphead [section]      [style=\bfb]
+%     \setuphead [subsection]   [style=\bfa]
+%     \setuphead [subsubsection][style=\bf]
+%
+% } {
+%
+%     \definetypeface[mainfacenormal]  [ss][sans] [iwona]       [default]
+%     \definetypeface[mainfacenormal]  [rm][serif][palatino]    [default]
+%     \definetypeface[mainfacenormal]  [tt][mono] [modern]      [default][rscale=1.1]
+%     \definetypeface[mainfacenormal]  [mm][math] [iwona]       [default]
+%
+%     \definetypeface[mainfacemedium]  [ss][sans] [iwona-medium][default]
+%     \definetypeface[mainfacemedium]  [rm][serif][palatino]    [default]
+%     \definetypeface[mainfacemedium]  [tt][mono] [modern]      [default][rscale=1.1]
+%     \definetypeface[mainfacemedium]  [mm][math] [iwona-medium][default]
+%
+%     \setupbodyfont
+%       [mainfacenormal,10pt]
+%
+%     \setuphead [chapter]      [style=\mainfacemedium\bfd]
+%     \setuphead [section]      [style=\mainfacemedium\bfb]
+%     \setuphead [subsection]   [style=\mainfacemedium\bfa]
+%     \setuphead [subsubsection][style=\mainfacemedium\bf]
+%
+% }
+
+\writestatus{luatex manual}{we assume that dejavu math is available}
+
+\setupbodyfont % assumes dejavu-math
+  [dejavu,10pt]
+
+\setuphead [chapter]      [align={flushleft,broad},style=\bfd]
+\setuphead [section]      [align={flushleft,broad},style=\bfb]
+\setuphead [subsection]   [align={flushleft,broad},style=\bfa]
+\setuphead [subsubsection][align={flushleft,broad},style=\bf]
+
+\setuphead [chapter]      [color=maincolor]
+\setuphead [section]      [color=maincolor]
+\setuphead [subsection]   [color=maincolor]
+\setuphead [subsubsection][color=maincolor]
+
+\definehead
+  [remark]
+  [subsubsubject]
+
+\setupheadertexts
+  []
+
+\definemixedcolumns
+  [twocolumns]
+  [n=2,
+   balance=yes,
+   before=\blank,
+   after=\blank]
+
+\definemixedcolumns
+  [threecolumns]
+  [twocolumns]
+  [n=3]
+
+\definemixedcolumns
+  [fourcolumns]
+  [threecolumns]
+  [n=4]
+
+% if we do this we also need to do it in table cells
+%
+% \setuptyping
+%   [color=maincolor]
+%
+% \setuptype
+%   [color=maincolor]
+
+\definetyping
+  [functioncall]
+
+\startMPdefinitions
+
+    color   luaplanetcolor ; luaplanetcolor := \MPcolor{maincolor} ;
+    color   luaholecolor   ; luaholecolor   := white ;
+    numeric luaextraangle  ; luaextraangle  := 0 ;
+    numeric luaorbitfactor ; luaorbitfactor := .25 ;
+
+    vardef lualogo = image (
+
+        % Graphic design by A. Nakonechnyj. Copyright (c) 1998, All rights reserved.
+
+        save d, r, p ; numeric d, r, p ;
+
+        d := sqrt(2)/4 ; r := 1/4 ; p := r/8 ;
+
+        fill fullcircle scaled 1
+            withcolor luaplanetcolor ;
+        draw fullcircle rotated 40.5 scaled (1+r)
+            dashed evenly scaled p
+            withpen pencircle scaled (p/2)
+            withcolor (luaorbitfactor * luaholecolor) ;
+        fill fullcircle scaled r shifted (d+1/8,d+1/8)
+            rotated - luaextraangle
+            withcolor luaplanetcolor ;
+        fill fullcircle scaled r shifted (d-1/8,d-1/8)
+            withcolor luaholecolor   ;
+        luaorbitfactor := .25 ;
+    )  enddef ;
+
+\stopMPdefinitions
+
+\startuseMPgraphic{luapage}
+    StartPage ;
+
+        fill Page withcolor \MPcolor{othercolor} ;
+
+        luaorbitfactor := 1 ;
+        picture p ; p := lualogo xsized (3PaperWidth/5) ;
+        draw p shifted center Page shifted (0,-.5ypart center ulcorner p) ;
+
+    StopPage ;
+\stopuseMPgraphic
+
+% \starttexdefinition luaextraangle
+%     % we can also just access the last page and so in mp directly
+%     \ctxlua {
+%         context(\lastpage == 0 and 0 or \realfolio*360/\lastpage)
+%     }
+% \stoptexdefinition
+
+\startuseMPgraphic{luanumber}
+  % luaextraangle  := \luaextraangle;
+    luaextraangle  := if (LastPageNumber == 0) : 0 else : (RealPageNumber / LastPageNumber) * 360  fi;
+    luaorbitfactor := 0.25 ;
+    picture p ; p := lualogo ;
+    setbounds p to boundingbox fullcircle ;
+    draw p ysized 1cm ;
+\stopuseMPgraphic
+
+\definelayer
+  [page]
+  [width=\paperwidth,
+   height=\paperheight]
+
+\setupbackgrounds
+  [leftpage]
+  [background=page]
+
+\setupbackgrounds
+  [rightpage]
+  [background=page]
+
+\startsetups pagenumber:right
+  \setlayerframed
+    [page]
+    [preset=rightbottom,offset=1cm]
+    [frame=off,height=1cm,offset=overlay]
+    {\useMPgraphic{luanumber}}
+  \setlayerframed
+    [page]
+    [preset=rightbottom,offset=1cm,x=1.5cm]
+    [frame=off,height=1cm,width=1cm,offset=overlay]
+    {\pagenumber}
+  \setlayerframed
+    [page]
+    [preset=rightbottom,offset=1cm,x=2.5cm]
+    [frame=off,height=1cm,offset=overlay]
+    {\getmarking[chapter]}
+\stopsetups
+
+\startsetups pagenumber:left
+  \setlayerframed
+    [page]
+    [preset=leftbottom,offset=1cm,x=2.5cm]
+    [frame=off,height=1cm,offset=overlay]
+    {\getmarking[chapter]}
+  \setlayerframed
+    [page]
+    [preset=leftbottom,offset=1cm,x=1.5cm]
+    [frame=off,height=1cm,width=1cm,offset=overlay]
+    {\pagenumber}
+  \setlayerframed
+    [page]
+    [preset=leftbottom,offset=1cm]
+    [frame=off,height=1cm,offset=overlay]
+    {\useMPgraphic{luanumber}}
+\stopsetups
+
+\unexpanded\def\nonterminal#1>{\mathematics{\langle\hbox{\rm #1}\rangle}}
+
+% taco's brainwave -) .. todo: create a typing variant so that we can avoid the !crlf
+
+\newcatcodetable\syntaxcodetable
+
+\unexpanded\def\makesyntaxcodetable
+  {\begingroup
+   \catcode`\<=13 \catcode`\|=12
+   \catcode`\!= 0 \catcode`\\=12
+   \savecatcodetable\syntaxcodetable
+   \endgroup}
+
+\makesyntaxcodetable
+
+\unexpanded\def\startsyntax {\begingroup\catcodetable\syntaxcodetable  \dostartsyntax}
+\unexpanded\def\syntax      {\begingroup\catcodetable\syntaxcodetable  \dosyntax}
+           \let\stopsyntax   \relax
+
+\unexpanded\def\syntaxenvbody#1%
+  {\par
+   \tt
+   \startnarrower
+   \maincolor #1
+   \stopnarrower
+   \par}
+
+\unexpanded\def\syntaxbody#1%
+  {\begingroup
+   \maincolor \tt #1%
+   \endgroup}
+
+\bgroup \catcodetable\syntaxcodetable
+
+!gdef!dostartsyntax#1\stopsyntax{!let<!nonterminal!syntaxenvbody{#1}!endgroup}
+!gdef!dosyntax     #1{!let<!nonterminal!syntaxbody{#1}!endgroup}
+
+!egroup
+
+\definetyping
+  [texsyntax]
+  [color=maincolor]
+
+% end of wave
+
+\setupinteraction
+  [state=start,
+   focus=standard,
+   style=,
+   color=,
+   contrastcolor=]
+
+\placebookmarks
+  [chapter,section,subsection]
+
+\setuplist
+  [chapter,section,subsection,subsubsection]
+  [interaction=all,
+   width=3em]
+
+\setuplist
+  [chapter]
+  [style=bold,
+   color=keptcolor]
+
+\setuplist
+  [subsection,subsubsection]
+  [margin=3em,
+   width=5em]
+
+% Hans doesn't like the bookmarks opening by default so we comment this:
+%
+% \setupinteractionscreen
+%   [option=bookmark]
+
+\stopenvironment
diff --git a/manual/luatex-tex.tex b/manual/luatex-tex.tex
index edf86870c6ab788d783dbd695eb3fd397ea9ed28..74af5976fc24f7c1a0109fc871d015311a1884cc 100644
--- a/manual/luatex-tex.tex
+++ b/manual/luatex-tex.tex
@@ -1505,27 +1505,16 @@ string if you only want to move to the next line.
 You can disable \type {^^} escaping of control characters by passing a value of
 zero.
 
-\section{The \type {token} libray}
-
-The current \type {token} library will be replaced by a new one that is more
-flexible and powerful. The transition takes place in steps. In version 0.80 we
-have \type {token} and in version 0.85 the old lib will be replaced
-completely. So if you use this new mechanism in production code you need to be
-aware of incompatible updates between 0.80 and 0.90. Because the related in- and
-output code will also be cleaned up and rewritten you should be aware of
-incompatible logging and error reporting too.
-
-The old library presents tokens as triplets or numbers, the new library presents
-a userdata object. The old library used a callback to intercept tokens in the
-input but the new library provides a basic scanner infrastructure that can be
-used to write macros that accept a wide range of arguments. This interface is on
+\section{The \type {token} library}
+
+The token library provides means to intercept the input and deal with it at the
+\LUA\ level. The library provides a basic scanner infrastructure that can be used
+to write macros that accept a wide range of arguments. This interface is on
 purpose kept general and as performance is quite ok one can build additional
 parsers without too much overhead. It's up to macro package writers to see how
 they can benefit from this as the main principle behind \LUATEX\ is to provide a
-minimal set of tools and no solutions.
-
-The current functions in the \type {token} namespace are given in the next
-table:
+minimal set of tools and no solutions. The functions provided in the \type
+{token} namespace are given in the next table:
 
 \starttabulate[|lT|lT|p|]
 \NC \bf function \NC \bf argument       \NC \bf result \NC \NR
diff --git a/manual/luatex.pdf b/manual/luatex.pdf
index 543b3cb53281be16a17a66a4c8cd71ef7f3db83c..7ee0ed561865c54f71ff0bb7e4b1349e22414aac 100644
Binary files a/manual/luatex.pdf and b/manual/luatex.pdf differ
diff --git a/manual/luatex.tex b/manual/luatex.tex
index c997835c56a823c11f40d2f49738af805479dcf4..6bcd1c4e8ab293a8863de662cad5f85a6b9ced7f 100644
--- a/manual/luatex.tex
+++ b/manual/luatex.tex
@@ -11,7 +11,7 @@
 \dontcomplain
 
 \startdocument
-  [version=0.96.0,
+  [version=0.97.0,
    status=Pre-release]
 
 \component luatex-titlepage
diff --git a/source/ChangeLog b/source/ChangeLog
index 3e8f73ad5c69ce375c3932893306fc3c6c19d77a..50b092be68a863f918f6a812f7a39bc4bc6bcad3 100644
--- a/source/ChangeLog
+++ b/source/ChangeLog
@@ -1,3 +1,12 @@
+2016-06-30  Karl Berry  <karl@tug.org>
+
+	* extra/epstopdf/epstopdf.pl: sort debugging lines, history (for
+		release to CTAN)
+
+	* version.ac (tex_live_version): 2016 => 2017/dev.
+	* tardate.ac (tex_live_tardate): 2015-05-12 => 2016-05-23.
+	(Though this is not used for any release.)
+
 2016-03-16  Karl Berry  <karl@tug.org>
 
 	* Build: check for exitstatus.txt not having an exit status.
@@ -579,3 +588,5 @@
 	* texk/web2c/omegadir/com16bit.ch, alephdir/com16bit-rc2.ch
 	(sup_main_memory, sup_save_size): increase per tex.ch.
 	From Akira.
+
+(This ChangeLog file public domain.)
diff --git a/source/build-aux/config.guess b/source/build-aux/config.guess
index 0967f2afa92a80d4afeb6fcf901bf7d55b13434f..c4bd827a7bedcf6f78866a27bf01d896c047b516 100755
--- a/source/build-aux/config.guess
+++ b/source/build-aux/config.guess
@@ -2,7 +2,7 @@
 # Attempt to guess a canonical system name.
 #   Copyright 1992-2016 Free Software Foundation, Inc.
 
-timestamp='2016-04-02'
+timestamp='2016-05-15'
 
 # 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
@@ -186,9 +186,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
 	esac
 	# The Operating System including object format, if it has switched
-	# to ELF recently, or will in the future.
+	# to ELF recently (or will in the future) and ABI.
 	case "${UNAME_MACHINE_ARCH}" in
-	    arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax)
+	    earm*)
+		os=netbsdelf
+		;;
+	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
 		eval $set_cc_for_build
 		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
 			| grep -q __ELF__
@@ -1408,18 +1411,17 @@ esac
 cat >&2 <<EOF
 $0: unable to guess system type
 
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
+This script (version $timestamp), has failed to recognize the
+operating system you are using. If your script is old, overwrite
+config.guess and config.sub with the latest versions from:
 
   http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
 and
   http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
 
-If the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches@gnu.org> in order to provide the needed
-information to handle your system.
+If $0 has already been updated, send the following data and any
+information you think might be pertinent to config-patches@gnu.org to
+provide the necessary information to handle your system.
 
 config.guess timestamp = $timestamp
 
diff --git a/source/build-aux/config.sub b/source/build-aux/config.sub
index 6d86a1e2f77b3f89d0ce8efa7741c611aa2d6edf..9feb73bf088fc285489d1e68aa0d6d4c96cb5768 100755
--- a/source/build-aux/config.sub
+++ b/source/build-aux/config.sub
@@ -2,7 +2,7 @@
 # Configuration validation subroutine script.
 #   Copyright 1992-2016 Free Software Foundation, Inc.
 
-timestamp='2016-05-10'
+timestamp='2016-06-20'
 
 # 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
@@ -643,6 +643,14 @@ case $basic_machine in
 		basic_machine=m68k-bull
 		os=-sysv3
 		;;
+	e500v[12])
+		basic_machine=powerpc-unknown
+		os=$os"spe"
+		;;
+	e500v[12]-*)
+		basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=$os"spe"
+		;;
 	ebmon29k)
 		basic_machine=a29k-amd
 		os=-ebmon
@@ -1389,7 +1397,7 @@ case $os in
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -chorusos* | -chorusrdb* | -cegcc* \
 	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-	      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+	      | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
 	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
 	      | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
diff --git a/source/build-aux/texinfo.tex b/source/build-aux/texinfo.tex
index 314063cafe18a2a5298ac35833377ed31f6db50f..daa7055bbbc002c94b06c7c4dea57d0eae8d4257 100644
--- a/source/build-aux/texinfo.tex
+++ b/source/build-aux/texinfo.tex
@@ -3,7 +3,7 @@
 % Load plain if necessary, i.e., if running under initex.
 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
 %
-\def\texinfoversion{2016-05-07.20}
+\def\texinfoversion{2016-06-18.21}
 %
 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
@@ -1192,6 +1192,7 @@ where each line of input produces a line of output.}
   \ifx\pdfescapestring\thisisundefined
     % No primitive available; should we give a warning or log?
     % Many times it won't matter.
+    \xdef#1{#1}%
   \else
     % The expandable \pdfescapestring primitive escapes parentheses,
     % backslashes, and other special chars.
@@ -1311,8 +1312,10 @@ output) for that.)}
     % We have to set dummies so commands such as @code, and characters
     % such as \, aren't expanded when present in a section title.
     \indexnofonts
-    \turnoffactive
     \makevalueexpandable
+    \turnoffactive
+    % Use ASCII approximations in destination names.
+    \passthroughcharsfalse
     \def\pdfdestname{#1}%
     \txiescapepdf\pdfdestname
     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
@@ -1357,8 +1360,21 @@ output) for that.)}
       \fi
       %
       % Also escape PDF chars in the display string.
-      \edef\pdfoutlinetext{#1}%
-      \txiescapepdf\pdfoutlinetext
+      \bgroup
+        \ifx \declaredencoding \latone
+          % The PDF format can use an extended form of Latin-1 in bookmark
+          % strings.  See Appendix D of the PDF Reference, Sixth Edition, for
+          % the "PDFDocEncoding".
+          \passthroughcharstrue
+        \fi
+        \ifx \declaredencoding \utfeight
+          % TODO: the PDF format can use UTF-16 in bookmark strings, but the
+          % code for this isn't done yet.
+        \fi
+        \globaldefs=1
+        \edef\pdfoutlinetext{#1}%
+        \txiescapepdf\pdfoutlinetext
+      \egroup
       %
       \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
     }
@@ -4606,6 +4622,31 @@ end
   \fi
 }
 
+% 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 
+% 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}%
+  \else
+    \csname SET#1\endcsname
+  \fi
+}
+
+% Used for @value's in index entries to form the sort key: expand the @value
+% if possible, otherwise sort late.
+\def\indexnofontsvalue#1{%
+  \expandafter\ifx\csname SET#1\endcsname\relax
+    ZZZZZZZ
+  \else
+    \csname SET#1\endcsname
+  \fi
+}
+
 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
 % with @set.
 % 
@@ -4747,7 +4788,7 @@ end
 
 % Define \doindex, the driver for all index macros.
 % Argument #1 is generated by the calling \fooindex macro,
-% and it the two-letter name of the index.
+% and it is the two-letter name of the index.
 
 \def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
 \def\doindexxxx #1{\doind{\indexname}{#1}}
@@ -4756,6 +4797,7 @@ end
 \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
 \def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}}
 
+
 % Used when writing an index entry out to an index file to prevent
 % expansion of Texinfo commands that can appear in an index entry.
 %
@@ -4774,9 +4816,11 @@ end
   \def\}{{\tt\char125}}%
   %
   % Do the redefinitions.
-  \commondummies
+  \definedummies
 }
 
+% Used for the aux and toc files, where @ is the escape character.
+%
 % For the aux and toc files, @ is the escape character.  So we want to
 % redefine everything using @ as the escape character (instead of
 % \realbackslash, still used for index files).  When everything uses @,
@@ -4789,30 +4833,35 @@ end
   \let\} = \rbraceatcmd
   %
   % Do the redefinitions.
-  \commondummies
+  \definedummies
   \otherbackslash
 }
 
-% Called from \indexdummies and \atdummies.
+% \definedummyword defines \#1 as \string\#1\space, thus effectively
+% preventing its expansion.  This is used only for control words,
+% not control letters, because the \space would be incorrect for
+% control characters, but is needed to separate the control word
+% from whatever follows.
 %
-\def\commondummies{%
-  % \definedummyword defines \#1 as \string\#1\space, thus effectively
-  % preventing its expansion.  This is used only for control words,
-  % not control letters, because the \space would be incorrect for
-  % control characters, but is needed to separate the control word
-  % from whatever follows.
-  %
-  % For control letters, we have \definedummyletter, which omits the
-  % space.
-  %
-  % These can be used both for control words that take an argument and
-  % those that do not.  If it is followed by {arg} in the input, then
-  % that will dutifully get written to the index (or wherever).
-  %
-  \def\definedummyword  ##1{\def##1{\string##1\space}}%
-  \def\definedummyletter##1{\def##1{\string##1}}%
-  \let\definedummyaccent\definedummyletter
+% These can be used both for control words that take an argument and
+% those that do not.  If it is followed by {arg} in the input, then
+% that will dutifully get written to the index (or wherever).
+%
+% For control letters, we have \definedummyletter, which omits the
+% space.
+%
+\def\definedummyword  #1{\def#1{\string#1\space}}%
+\def\definedummyletter#1{\def#1{\string#1}}%
+\let\definedummyaccent\definedummyletter
+
+% Called from \indexdummies and \atdummies, to effectively prevent
+% the expansion of commands.
+%
+\def\definedummies{%
   %
+  \let\commondummyword\definedummyword
+  \let\commondummyletter\definedummyletter
+  \let\commondummyaccent\definedummyaccent
   \commondummiesnofonts
   %
   \definedummyletter\_%
@@ -4892,82 +4941,82 @@ end
   %
   % We want to disable all macros so that they are not expanded by \write.
   \macrolist
-  \definedummyword\value
+  \let\value\dummyvalue
   %
   \normalturnoffactive
 }
 
-% \commondummiesnofonts: common to \commondummies and \indexnofonts.
-% Define \definedumyletter, \definedummyaccent and \definedummyword before
-% using.
+% \commondummiesnofonts: common to \definedummies and \indexnofonts.
+% Define \commondummyletter, \commondummyaccent and \commondummyword before
+% using.  Used for accents, font commands, and various control letters.
 %
 \def\commondummiesnofonts{%
   % Control letters and accents.
-  \definedummyletter\!%
-  \definedummyaccent\"%
-  \definedummyaccent\'%
-  \definedummyletter\*%
-  \definedummyaccent\,%
-  \definedummyletter\.%
-  \definedummyletter\/%
-  \definedummyletter\:%
-  \definedummyaccent\=%
-  \definedummyletter\?%
-  \definedummyaccent\^%
-  \definedummyaccent\`%
-  \definedummyaccent\~%
-  \definedummyword\u
-  \definedummyword\v
-  \definedummyword\H
-  \definedummyword\dotaccent
-  \definedummyword\ogonek
-  \definedummyword\ringaccent
-  \definedummyword\tieaccent
-  \definedummyword\ubaraccent
-  \definedummyword\udotaccent
-  \definedummyword\dotless
+  \commondummyletter\!%
+  \commondummyaccent\"%
+  \commondummyaccent\'%
+  \commondummyletter\*%
+  \commondummyaccent\,%
+  \commondummyletter\.%
+  \commondummyletter\/%
+  \commondummyletter\:%
+  \commondummyaccent\=%
+  \commondummyletter\?%
+  \commondummyaccent\^%
+  \commondummyaccent\`%
+  \commondummyaccent\~%
+  \commondummyword\u
+  \commondummyword\v
+  \commondummyword\H
+  \commondummyword\dotaccent
+  \commondummyword\ogonek
+  \commondummyword\ringaccent
+  \commondummyword\tieaccent
+  \commondummyword\ubaraccent
+  \commondummyword\udotaccent
+  \commondummyword\dotless
   %
   % Texinfo font commands.
-  \definedummyword\b
-  \definedummyword\i
-  \definedummyword\r
-  \definedummyword\sansserif
-  \definedummyword\sc
-  \definedummyword\slanted
-  \definedummyword\t
+  \commondummyword\b
+  \commondummyword\i
+  \commondummyword\r
+  \commondummyword\sansserif
+  \commondummyword\sc
+  \commondummyword\slanted
+  \commondummyword\t
   %
   % Commands that take arguments.
-  \definedummyword\abbr
-  \definedummyword\acronym
-  \definedummyword\anchor
-  \definedummyword\cite
-  \definedummyword\code
-  \definedummyword\command
-  \definedummyword\dfn
-  \definedummyword\dmn
-  \definedummyword\email
-  \definedummyword\emph
-  \definedummyword\env
-  \definedummyword\file
-  \definedummyword\image
-  \definedummyword\indicateurl
-  \definedummyword\inforef
-  \definedummyword\kbd
-  \definedummyword\key
-  \definedummyword\math
-  \definedummyword\option
-  \definedummyword\pxref
-  \definedummyword\ref
-  \definedummyword\samp
-  \definedummyword\strong
-  \definedummyword\tie
-  \definedummyword\U
-  \definedummyword\uref
-  \definedummyword\url
-  \definedummyword\var
-  \definedummyword\verb
-  \definedummyword\w
-  \definedummyword\xref
+  \commondummyword\abbr
+  \commondummyword\acronym
+  \commondummyword\anchor
+  \commondummyword\cite
+  \commondummyword\code
+  \commondummyword\command
+  \commondummyword\dfn
+  \commondummyword\dmn
+  \commondummyword\email
+  \commondummyword\emph
+  \commondummyword\env
+  \commondummyword\file
+  \commondummyword\image
+  \commondummyword\indicateurl
+  \commondummyword\inforef
+  \commondummyword\kbd
+  \commondummyword\key
+  \commondummyword\math
+  \commondummyword\option
+  \commondummyword\pxref
+  \commondummyword\ref
+  \commondummyword\samp
+  \commondummyword\strong
+  \commondummyword\tie
+  \commondummyword\U
+  \commondummyword\uref
+  \commondummyword\url
+  \commondummyword\var
+  \commondummyword\verb
+  \commondummyword\w
+  \commondummyword\xref
 }
 
 % For testing: output @{ and @} in index sort strings as \{ and \}.
@@ -5023,11 +5072,11 @@ end
 %
 \def\indexnofonts{%
   % Accent commands should become @asis.
-  \def\definedummyaccent##1{\let##1\asis}%
+  \def\commondummyaccent##1{\let##1\asis}%
   % We can just ignore other control letters.
-  \def\definedummyletter##1{\let##1\empty}%
+  \def\commondummyletter##1{\let##1\empty}%
   % All control words become @asis by default; overrides below.
-  \let\definedummyword\definedummyaccent
+  \let\commondummyword\commondummyaccent
   \commondummiesnofonts
   %
   % Don't no-op \tt, since it isn't a user-level command
@@ -5112,8 +5161,11 @@ end
   % goes to end-of-line is not handled.
   %
   \macrolist
+  \let\value\indexnofontsvalue
 }
 
+
+
 
 \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
 
@@ -5912,18 +5964,32 @@ end
         \global\advance\dimen@ by 1pt
       \repeat
     }%
-    \multiply\dimen@ii by 4
-    \divide\dimen@ii by 5
-    \ifdim\ht3<\dimen@ii
-      % Column heights are too different, so don't make their bottoms
-      % flush with each other.  The glue at the end of the second column
-      % allows a second column to stretch, reducing the difference in
-      % height between the two.
-      \setbox0=\vbox to\dimen@{\unvbox1\vfill}%
-      \setbox2=\vbox to\dimen@{\unvbox3\vskip 0pt plus 0.3\ht0}%
+    \ifdim2\ht1>\vsize
+      % The left column has come out longer 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).  Just split the last
+      % of the double column material roughly in half.
+      \setbox2=\box0
+      \setbox0 = \vsplit2 to \dimen@ii
+      \setbox0=\vbox to\dimen@ii{\unvbox0}%
+      \setbox2=\vbox to\dimen@ii{\unvbox2}%
     \else
-      \setbox0=\vbox to\dimen@{\unvbox1}%
-      \setbox2=\vbox to\dimen@{\unvbox3}%
+      \multiply\dimen@ii by 5
+      \divide\dimen@ii by 4
+      \global\setbox3 = \copy0
+      \global\setbox1 = \vsplit3 to \dimen@ii
+      \global\setbox\balancedcolumns=\vbox{\pagesofar}%
+      \ifdim\ht3<\dimen@ii
+        % Column heights are too different, so don't make their bottoms
+        % flush with each other.  The glue at the end of the second column
+        % allows a second column to stretch, reducing the difference in
+        % height between the two.
+        \setbox0=\vbox to\dimen@{\unvbox1\vfill}%
+        \setbox2=\vbox to\dimen@{\unvbox3\vskip 0pt plus 0.3\ht0}%
+      \else
+        \setbox0=\vbox to\dimen@{\unvbox1}%
+        \setbox2=\vbox to\dimen@{\unvbox3}%
+      \fi
     \fi
   \fi
   %
@@ -8707,6 +8773,8 @@ end
     {%
       \requireauxfile
       \atdummies  % preserve commands, but don't expand them
+      % match definition in \xrdef, \refx, \xrefX.
+      \def\value##1{##1}%
       \edef\writexrdef##1##2{%
 	\write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
 	  ##1}{##2}}% these are parameters of \writexrdef
@@ -10212,7 +10280,7 @@ directory should work if nowhere else does.}
   \countUTFx = "80
   \countUTFy = "C2
   \def\UTFviiiTmp{%
-    \gdef~{
+    \gdef~{%
         \ifpassthroughchars $\fi}}%
   \UTFviiiLoop
 
@@ -10263,6 +10331,15 @@ directory should work if nowhere else does.}
   \fi
 }
 
+% These macros are used here to construct the name of a control
+% sequence to be defined.
+\def\UTFviiiTwoOctetsName#1#2{%
+  \csname u8:#1\string #2\endcsname}%
+\def\UTFviiiThreeOctetsName#1#2#3{%
+  \csname u8:#1\string #2\string #3\endcsname}%
+\def\UTFviiiFourOctetsName#1#2#3#4{%
+  \csname u8:#1\string #2\string #3\string #4\endcsname}%
+
 % For UTF-8 byte sequence (TeX, e-TeX and pdfTeX)
 % Definition macro to replace the Unicode character
 % Definition macro that is used by @U command
@@ -10279,17 +10356,18 @@ directory should work if nowhere else does.}
     \countUTFz = "#1\relax
     \begingroup
       \parseXMLCharref
+    
+      % Give \u8:... its definition.  The sequence of seven \expandafter's
+      % expands after the \gdef three times, e.g.
       %
-      % Access definitions of characters given UTF-8 sequences
-      \def\UTFviiiTwoOctets##1##2{%
-        \csname u8:##1\string ##2\endcsname}%
-      \def\UTFviiiThreeOctets##1##2##3{%
-        \csname u8:##1\string ##2\string ##3\endcsname}%
-      \def\UTFviiiFourOctets##1##2##3##4{%
-        \csname u8:##1\string ##2\string ##3\string ##4\endcsname}%
-      \expandafter\expandafter\expandafter\expandafter
-       \expandafter\expandafter\expandafter
-       \gdef\UTFviiiTmp{#2}%
+      % 1.  \UTFviiTwoOctetsName B1 B2
+      % 2.  \csname u8:B1 \string B2 \endcsname
+      % 3.  \u8: B1 B2  (a single control sequence token)
+      %
+      \expandafter\expandafter
+      \expandafter\expandafter
+      \expandafter\expandafter
+      \expandafter\gdef       \UTFviiiTmp{#2}%
       % 
       \expandafter\ifx\csname uni:#1\endcsname \relax \else
        \message{Internal error, already defined: #1}%
@@ -10299,37 +10377,53 @@ directory should work if nowhere else does.}
       \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
     \endgroup}
   %
-  % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp.
+  % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp
+  % to the corresponding UTF-8 sequence.
   \gdef\parseXMLCharref{%
     \ifnum\countUTFz < "A0\relax
       \errhelp = \EMsimple
       \errmessage{Cannot define Unicode char value < 00A0}%
     \else\ifnum\countUTFz < "800\relax
       \parseUTFviiiA,%
-      \parseUTFviiiB C\UTFviiiTwoOctets.,%
+      \parseUTFviiiB C\UTFviiiTwoOctetsName.,%
     \else\ifnum\countUTFz < "10000\relax
       \parseUTFviiiA;%
       \parseUTFviiiA,%
-      \parseUTFviiiB E\UTFviiiThreeOctets.{,;}%
+      \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}%
     \else
       \parseUTFviiiA;%
       \parseUTFviiiA,%
       \parseUTFviiiA!%
-      \parseUTFviiiB F\UTFviiiFourOctets.{!,;}%
+      \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}%
     \fi\fi\fi
   }
 
+  % Extract a byte from the end of the UTF-8 representation of \countUTFx.
+  % It must be a non-initial byte in the sequence.
+  % Change \uccode of #1 for it to be used in \parseUTFviiiB as one
+  % of the bytes.
   \gdef\parseUTFviiiA#1{%
     \countUTFx = \countUTFz
     \divide\countUTFz by 64
-    \countUTFy = \countUTFz
+    \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
+
+    % Convert this to the byte in the UTF-8 sequence.
     \advance\countUTFx by 128
     \uccode `#1\countUTFx
     \countUTFz = \countUTFy}
 
-  % Used to set \UTFviiiTmp to a UTF-8 byte sequence
+  % Used to put a UTF-8 byte sequence into \UTFviiiTmp
+  % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8
+  %    sequence.
+  % #2 is one of the \UTFviii*OctetsName macros.
+  % #3 is always a full stop (.)
+  % #4 is a template for the other bytes in the sequence.  The values for these
+  %    bytes is substituted in here with \uppercase using the \uccode's.
   \gdef\parseUTFviiiB#1#2#3#4{%
     \advance\countUTFz by "#10\relax
     \uccode `#3\countUTFz
diff --git a/source/configure b/source/configure
index fef3121e247af1ace0983ba568ab1ca54a240565..587a6fd1265c817f7c092953b26fa83d69a76504 100755
--- a/source/configure
+++ b/source/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for TeX Live 2015-06-12.
+# Generated by GNU Autoconf 2.69 for TeX Live 2016-05-23.
 #
 # Report bugs to <tex-k@tug.org>.
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='TeX Live'
 PACKAGE_TARNAME='tex-live'
-PACKAGE_VERSION='2015-06-12'
-PACKAGE_STRING='TeX Live 2015-06-12'
+PACKAGE_VERSION='2016-05-23'
+PACKAGE_STRING='TeX Live 2016-05-23'
 PACKAGE_BUGREPORT='tex-k@tug.org'
 PACKAGE_URL=''
 
@@ -1426,7 +1426,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures TeX Live 2015-06-12 to adapt to many kinds of systems.
+\`configure' configures TeX Live 2016-05-23 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1500,7 +1500,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of TeX Live 2015-06-12:";;
+     short | recursive ) echo "Configuration of TeX Live 2016-05-23:";;
    esac
   cat <<\_ACEOF
 
@@ -1713,7 +1713,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-TeX Live configure 2015-06-12
+TeX Live configure 2016-05-23
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2490,7 +2490,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by TeX Live $as_me 2015-06-12, which was
+It was created by TeX Live $as_me 2016-05-23, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -9111,7 +9111,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='tex-live'
- VERSION='2015-06-12'
+ VERSION='2016-05-23'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -20752,7 +20752,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by TeX Live $as_me 2015-06-12, which was
+This file was extended by TeX Live $as_me 2016-05-23, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -20809,7 +20809,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-TeX Live config.status 2015-06-12
+TeX Live config.status 2016-05-23
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
@@ -22765,11 +22765,11 @@ msg_compiling="$msg_compiling
 test "x$srcdir" = x. || msg_compiling="$msg_compiling
       from sources in $kpse_src"
 { $as_echo "$as_me:${as_lineno-$LINENO}: result:
-** Configuration summary for $PACKAGE_STRING (2016$with_banner_add):
+** Configuration summary for $PACKAGE_STRING (2017/dev$with_banner_add):
 
    $msg_compiling" >&5
 $as_echo "
-** Configuration summary for $PACKAGE_STRING (2016$with_banner_add):
+** Configuration summary for $PACKAGE_STRING (2017/dev$with_banner_add):
 
    $msg_compiling" >&6; }
 case $kpse_src$kpse_bld in
diff --git a/source/libs/README b/source/libs/README
index 17fc951ad621433bd13cc5ff6ddd6311fe8885d7..0eb762f4282d88c5b743c0deaa8d93b5c206dd16 100644
--- a/source/libs/README
+++ b/source/libs/README
@@ -1,4 +1,4 @@
-$Id: README 40358 2016-04-09 00:38:06Z kakuto $
+$Id: README 41496 2016-06-19 09:24:37Z kakuto $
 Public domain.  Originally created by Karl Berry, 2005.
 
 Libraries we compile for TeX Live.
@@ -18,13 +18,13 @@ freetype2 2.6.3 - checked 12feb16
 gd 2.1.1 - checked 14jan15
   https://bitbucket.org/libgd/gd-libgd/downloads/
 
-gmp 6.1.0 - checked 28dec15
+gmp 6.1.1 - checked 19jun16
   http://ftp.gnu.org/gnu/gmp/
 
 graphite2 1.3.8 - checked 31mar16
   http://sourceforge.net/projects/silgraphite/files/graphite2/
 
-harfbuzz 1.2.6 - checked 09apr16
+harfbuzz 1.2.7 - checked 07jun16
   http://www.freedesktop.org/software/harfbuzz/release/
 
 icu 57.1 (release) - checked 27mar16
@@ -33,7 +33,7 @@ icu 57.1 (release) - checked 27mar16
 libpaper 1.1.24+nmu2 - checked 24oct13
   ftp://ftp.de.debian.org/debian/pool/main/libp/libpaper/
 
-libpng 1.6.21 - checked 15jan16
+libpng 1.6.23 - checked 09jun16
   http://www.libpng.org/ - used by many
   http://www.libpng.org/pub/png/pngcode.html
 
@@ -49,7 +49,7 @@ mpfr 3.1.4 - checked 07mar16
 pixman 0.34.0 - checked 04feb16
   http://cairographics.org/releases/
 
-poppler 0.42.0 - checked 18mar16
+poppler 0.45.0 - checked 18jun16
   http://poppler.freedesktop.org/ - used by luatex and xetex
 
 potrace 1.13 - checked 28dec15
diff --git a/source/libs/configure b/source/libs/configure
index c03df7a810f6433c482fc2bf8d136abecfc0a8e6..72719d2686bb23c2cc07263faaf3a46c7b730047 100755
--- a/source/libs/configure
+++ b/source/libs/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for TeX Live libs 2016.
+# Generated by GNU Autoconf 2.69 for TeX Live libs 2017/dev.
 #
 # Report bugs to <tex-k@tug.org>.
 #
@@ -579,8 +579,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='TeX Live libs'
 PACKAGE_TARNAME='tex-live-libs'
-PACKAGE_VERSION='2016'
-PACKAGE_STRING='TeX Live libs 2016'
+PACKAGE_VERSION='2017/dev'
+PACKAGE_STRING='TeX Live libs 2017/dev'
 PACKAGE_BUGREPORT='tex-k@tug.org'
 PACKAGE_URL=''
 
@@ -1327,7 +1327,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures TeX Live libs 2016 to adapt to many kinds of systems.
+\`configure' configures TeX Live libs 2017/dev to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1397,7 +1397,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of TeX Live libs 2016:";;
+     short | recursive ) echo "Configuration of TeX Live libs 2017/dev:";;
    esac
   cat <<\_ACEOF
 
@@ -1587,7 +1587,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-TeX Live libs configure 2016
+TeX Live libs configure 2017/dev
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1688,7 +1688,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by TeX Live libs $as_me 2016, which was
+It was created by TeX Live libs $as_me 2017/dev, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -4520,7 +4520,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='tex-live-libs'
- VERSION='2016'
+ VERSION='2017/dev'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -5514,7 +5514,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by TeX Live libs $as_me 2016, which was
+This file was extended by TeX Live libs $as_me 2017/dev, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5571,7 +5571,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-TeX Live libs config.status 2016
+TeX Live libs config.status 2017/dev
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/source/libs/gmp/ChangeLog b/source/libs/gmp/ChangeLog
index 18252dcc02335f8192fd63604b8f5c378c5d903f..99969c99fb4c537df5aa697f76769a09d68031e5 100644
--- a/source/libs/gmp/ChangeLog
+++ b/source/libs/gmp/ChangeLog
@@ -1,3 +1,7 @@
+2016-06-19  Akira Kakuto  <kakuto@fuk.kindai.ac.jp>
+
+	Import gmp-6.1.1.
+
 2016-02-15  Karl Berry  <karl@tug.org>
 
 	* gmp-PATCHES: rename from gmp-src-PATCHES.
diff --git a/source/libs/gmp/configure b/source/libs/gmp/configure
index 06504a8992d44a29b7d872e973a7f2bbfd4ba68c..d174848b641a1c49ca66b324cc3574fae1497508 100755
--- a/source/libs/gmp/configure
+++ b/source/libs/gmp/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for gmp (TeX Live) 6.1.0.
+# Generated by GNU Autoconf 2.69 for gmp (TeX Live) 6.1.1.
 #
 # Report bugs to <tex-k@tug.org>.
 #
@@ -580,8 +580,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='gmp (TeX Live)'
 PACKAGE_TARNAME='gmp--tex-live-'
-PACKAGE_VERSION='6.1.0'
-PACKAGE_STRING='gmp (TeX Live) 6.1.0'
+PACKAGE_VERSION='6.1.1'
+PACKAGE_STRING='gmp (TeX Live) 6.1.1'
 PACKAGE_BUGREPORT='tex-k@tug.org'
 PACKAGE_URL=''
 
@@ -1294,7 +1294,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures gmp (TeX Live) 6.1.0 to adapt to many kinds of systems.
+\`configure' configures gmp (TeX Live) 6.1.1 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1364,7 +1364,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of gmp (TeX Live) 6.1.0:";;
+     short | recursive ) echo "Configuration of gmp (TeX Live) 6.1.1:";;
    esac
   cat <<\_ACEOF
 
@@ -1461,7 +1461,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-gmp (TeX Live) configure 6.1.0
+gmp (TeX Live) configure 6.1.1
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1976,7 +1976,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by gmp (TeX Live) $as_me 6.1.0, which was
+It was created by gmp (TeX Live) $as_me 6.1.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3899,7 +3899,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='gmp--tex-live-'
- VERSION='6.1.0'
+ VERSION='6.1.1'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -6148,7 +6148,7 @@ else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include "gmp-tmp.h"
-#include "$srcdir/gmp-6.1.0/gmp-impl.h"
+#include "$srcdir/gmp-6.1.1/gmp-impl.h"
 int
 main ()
 {
@@ -7002,7 +7002,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by gmp (TeX Live) $as_me 6.1.0, which was
+This file was extended by gmp (TeX Live) $as_me 6.1.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -7068,7 +7068,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-gmp (TeX Live) config.status 6.1.0
+gmp (TeX Live) config.status 6.1.1
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/source/libs/gmp/gmp-PATCHES/ChangeLog b/source/libs/gmp/gmp-PATCHES/ChangeLog
index 12e4e93b6963015693246e4b95526aba4eb978fb..cc5c4ac277f037c727749f630af7856d612a3031 100644
--- a/source/libs/gmp/gmp-PATCHES/ChangeLog
+++ b/source/libs/gmp/gmp-PATCHES/ChangeLog
@@ -1,3 +1,7 @@
+2016-06-19  Akira Kakuto  <kakuto@fuk.kindai.ac.jp>
+
+	* Import 6.1.1.
+
 2015-12-28  Akira Kakuto  <kakuto@fuk.kindai.ac.jp>
 
 	* patch-01-const: Removed, since it is applied in 6.1.0.
diff --git a/source/libs/gmp/gmp-PATCHES/TL-Changes b/source/libs/gmp/gmp-PATCHES/TL-Changes
index 5b403d1df854551614d3a30fa693766803feb8ea..63b34ce4871554039a75f882861e030ce2665b97 100644
--- a/source/libs/gmp/gmp-PATCHES/TL-Changes
+++ b/source/libs/gmp/gmp-PATCHES/TL-Changes
@@ -1,4 +1,4 @@
-Changes applied to the gmp-6.1.0/ tree as obtained from:
+Changes applied to the gmp-6.1.1/ tree as obtained from:
 	http://ftp.gnu.org/gnu/gmp/
 
 Removed:
diff --git a/source/libs/gmp/gmp-src/ChangeLog b/source/libs/gmp/gmp-src/ChangeLog
index 879b3106a343385b72393e103b45d29f4e69633b..3ffe795396a583af5d696ad52a5a992c8cdbc0fe 100644
--- a/source/libs/gmp/gmp-src/ChangeLog
+++ b/source/libs/gmp/gmp-src/ChangeLog
@@ -1,3 +1,80 @@
+2016-06-18  Torbjörn Granlund  <tg@gmplib.org>
+
+	* Version 6.1.1 released.
+
+2015-03-20  Marc Glisse  <marc.glisse@inria.fr>
+
+	* configure.ac (WANT_ASSEMBLY): Remove.
+	(NO_ASM): Remove from CFLAGS, add to AC_DEFINE.
+	* tests/misc.c: Test NO_ASM instead of WANT_ASSEMBLY.
+
+2016-02-25  Pavel Kopyl  <p.kopyl@samsung.com>
+
+	* acinclude.m4 (GMP_ASM_UNDERSCORE): Tighten gurkmacka detection.
+
+2016-01-04 Marco Bodrato <bodrato@mail.dm.unipi.it>
+
+	* Makefile.am (LIBGMP_LT_*, LIBGMPXX_LT_*): Bump version info.
+	* gmp-h.in: Bump version.
+
+2016-01-01 Marco Bodrato <bodrato@mail.dm.unipi.it>
+
+	* tests/cxx/clocale.c: Do not re-define localeconv for mingw.
+	* tests/misc/t-locale.c: Likewise (Thanks Alexander).
+
+2015-12-26  Torbjörn Granlund  <torbjorng@google.com>
+
+	* tests/misc.c (tests_start): Assert library version.
+
+2015-12-19  Marc Glisse  <marc.glisse@inria.fr>
+
+	* gmp-impl.h (fft_table_nk): Use gmp_uint_least32_t.
+	* mpn/generic/trialdiv.c (gmp_primes_ptab): Likewise.
+
+2015-12-14  Torbjörn Granlund  <torbjorng@google.com>
+
+	* mpn/x86_64/fat/fat.c (gmp_workaround_skylake_cpuid_bug):
+	New function.
+	(__gmpn_cpuvec_init): Handle more BMI2 crippled CPUs.
+
+2015-12-13 Marco Bodrato <bodrato@mail.dm.unipi.it>
+
+	* tests/arm32call.asm: bx->ret to support thumb-less chips 
+	  (thanks Martin Husemann).
+
+2015-12-13  Torbjörn Granlund  <torbjorng@google.com>
+
+	* config.sub: Fix spelling of kabylake.
+	* acinclude.m4: Likewise.
+	* mpn/x86_64/fat/fat.c: Likewise.
+
+2015-12-10 Marco Bodrato <bodrato@mail.dm.unipi.it>
+
+	* tests/misc/t-printf.c: Test a sequence of '%'.
+	* printf/doprnt.c: Avoid buffer overread with long long limbs.
+
+2015-12-06  Torbjörn Granlund  <torbjorng@google.com>
+
+	* configure.ac (arm*): Conditionally define NOTHUMB.
+	Simplify and generalise.
+	* mpn/arm/arm-defs.m4 (ret): New macro, conditional on NOTHUMB.
+	* mpn/arm/*.asm: Use ret.
+
+2015-12-03  Torbjörn Granlund  <torbjorng@google.com>
+
+	* config.guess: Work around skylake cpuid bug.
+	Fix spelling of kabylake.
+
+2015-12-01  Torbjörn Granlund  <torbjorng@google.com>
+
+	* mpn/x86_64/coreibwl/mul_basecase.asm: Add FUNC_EXITs.
+
+2015-11-21 Marco Bodrato <bodrato@mail.dm.unipi.it>
+
+	* gmp-impl.h (MPN_TOOM22_MUL_MINSIZE): Consider ToomX2 limits
+	  (thanks Paul).
+	* tests/mpn/t-toom22.c: Keep on testing small sizes.
+
 2015-11-01 Marco Bodrato <bodrato@mail.dm.unipi.it>
 
 	* Version 6.1.0 released.
@@ -673,7 +750,7 @@
 
 	* tune/tune-gcd-p.c: Add casts for C++ compatibility.
 
-	* tune/tuneup.c:  Add casts for C++ compatibility.
+	* tune/tuneup.c: Add casts for C++ compatibility.
 	(mpn_divrem_1_tune, mpn_mod_1_tune): Mark as extern "C".
 	(INSERT_FFTTAB): Produce sentinels differently to silence compiler.
 
@@ -701,12 +778,12 @@
 
 	* mpn/powerpc32/addmul_1.asm: Avoid negative stack pointer references.
 	* mpn/powerpc32/lshift.asm: Likewise.
-	* mpn/powerpc32/lshiftc.asm:  Likewise.
-	* mpn/powerpc32/p3-p7/aors_n.asm:  Likewise.
-	* mpn/powerpc32/rshift.asm:  Likewise.
-	* mpn/powerpc32/sec_tabselect.asm:  Likewise.
-	* mpn/powerpc32/submul_1.asm:  Likewise.
-	* mpn/powerpc32/vmx/mod_34lsub1.asm:  Likewise.
+	* mpn/powerpc32/lshiftc.asm: Likewise.
+	* mpn/powerpc32/p3-p7/aors_n.asm: Likewise.
+	* mpn/powerpc32/rshift.asm: Likewise.
+	* mpn/powerpc32/sec_tabselect.asm: Likewise.
+	* mpn/powerpc32/submul_1.asm: Likewise.
+	* mpn/powerpc32/vmx/mod_34lsub1.asm: Likewise.
 
 2014-10-13  Torbjörn Granlund  <torbjorng@google.com>
 
@@ -2033,8 +2110,8 @@
 
 	* mpn/powerpc64/mode64/divrem_1.asm: Remove explicit nop after CALL.
 	* mpn/powerpc64/mode64/divrem_2.asm: Likewise.
-	* mpn/powerpc64/mode64/mod_1_1.asm:  Likewise.
-	* mpn/powerpc64/mode64/mod_1_4.asm:  Likewise.
+	* mpn/powerpc64/mode64/mod_1_1.asm: Likewise.
+	* mpn/powerpc64/mode64/mod_1_4.asm: Likewise.
 
 2013-07-13  Torbjorn Granlund  <tege@gmplib.org>
 
@@ -2429,7 +2506,7 @@
 	* mpn/arm/dive_1.asm: New file.
 	* mpn/arm/v6/dive_1.asm: New file.
 
-	* mpn/arm/v6t2/mode1o.asm:  Make trivial change to avoid v6t2...
+	* mpn/arm/v6t2/mode1o.asm: Make trivial change to avoid v6t2...
 	* mpn/arm/v6/mode1o.asm: ...instruction, move file accordingly.
 
 	* mpn/powerpc64/mode64/invert_limb.asm: Put all multiplies low-limb first.
@@ -4777,7 +4854,7 @@
 	Reintroduce previously removed RP argument.
 	* mpn/x86_64/redc_1.asm: Likewise.
 
-	* mpn/generic/redc_2.c:  Remove mpn_sub_n call, return carry from
+	* mpn/generic/redc_2.c: Remove mpn_sub_n call, return carry from
 	mpn_add_n call.
 
 	* gmp-impl.h (mpn_redc_1, mpn_redc_2): Now return an mp_limb_t.
diff --git a/source/libs/gmp/gmp-src/Makefile.am b/source/libs/gmp/gmp-src/Makefile.am
index 453c6097a8b5cbde69afee90ecdbb2389c026686..4d26b8b573bd53fffbb8d0b58391348a1456a9a2 100644
--- a/source/libs/gmp/gmp-src/Makefile.am
+++ b/source/libs/gmp/gmp-src/Makefile.am
@@ -1,7 +1,7 @@
 ## Process this file with automake to generate Makefile.in
 
 
-# Copyright 1991, 1993, 1994, 1996, 1997, 1999-2004, 2006-2009, 2011-2015 Free
+# Copyright 1991, 1993, 1994, 1996, 1997, 1999-2004, 2006-2009, 2011-2016 Free
 # Software Foundation, Inc.
 #
 #  This file is part of the GNU MP Library.
@@ -87,6 +87,7 @@
 #        5.1.2   11:2:1    7:2:3     -
 #        6.0.0   12:0:2    8:0:4     -
 #        6.1.0   13:0:3    9:0:5     -
+#        6.1.1   13:1:3    9:1:5     -
 #
 # Starting at 3:0:0 is a slight abuse of the versioning system, but it
 # ensures we're past soname libgmp.so.2, which was used on Debian GNU/Linux
@@ -100,11 +101,11 @@
 # libgmpxx.so.3.0.4) incrementing, to make it clear which GMP it's from.
 
 LIBGMP_LT_CURRENT    = 13
-LIBGMP_LT_REVISION   = 0
+LIBGMP_LT_REVISION   = 1
 LIBGMP_LT_AGE        = 3
 
 LIBGMPXX_LT_CURRENT  = 9
-LIBGMPXX_LT_REVISION = 0
+LIBGMPXX_LT_REVISION = 1
 LIBGMPXX_LT_AGE      = 5
 
 
diff --git a/source/libs/gmp/gmp-src/NEWS b/source/libs/gmp/gmp-src/NEWS
index 111acb70fb2d8ef70470b1ae4b457e3cdb71c223..ffa7083260f3fbf9d2a99ed1ee835838546ec6c8 100644
--- a/source/libs/gmp/gmp-src/NEWS
+++ b/source/libs/gmp/gmp-src/NEWS
@@ -1,9 +1,20 @@
-Copyright 1996, 1999-2015 Free Software Foundation, Inc.
+Copyright 1996, 1999-2016 Free Software Foundation, Inc.
 
 Verbatim copying and distribution of this entire article is permitted in any
 medium, provided this notice is preserved.
 
 
+Changes between GMP version 6.1.0 and 6.1.1
+
+  BUGS FIXED
+  * Make Intel Broadwell configurations work on Windows.
+
+  FEATURES
+  * Work around faulty cpuid on some recent Intel chips (this allows GMP to run
+    on Skylake Pentiums).
+
+  * Support thumb-less ARM chips.
+
 Changes between GMP version 6.0.* and 6.1.0
 
   BUGS FIXED
diff --git a/source/libs/gmp/gmp-src/acinclude.m4 b/source/libs/gmp/gmp-src/acinclude.m4
index f6e8940ac005ef3dcfd68b767aa821cf3c5a4733..bcc6f524cd8626ea25cb779d3658ae91b1c05f81 100644
--- a/source/libs/gmp/gmp-src/acinclude.m4
+++ b/source/libs/gmp/gmp-src/acinclude.m4
@@ -63,7 +63,7 @@ define(X86_PATTERN,
 [[i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-* | viac3*-*-* | geode*-*-* | atom-*-*]])
 
 define(X86_64_PATTERN,
-[[athlon64-*-* | k8-*-* | k10-*-* | bobcat-*-* | jaguar*-*-* | bulldozer*-*-* | piledriver*-*-* | steamroller*-*-* | excavator*-*-* | pentium4-*-* | atom-*-* | silvermont-*-* | goldmont-*-* | core2-*-* | corei*-*-* | x86_64-*-* | nano-*-* | nehalem*-*-* | westmere*-*-* | sandybridge*-*-* | ivybridge*-*-* | haswell*-*-* | broadwell*-*-* | skylake*-*-* | cabylake*-*-*]])
+[[athlon64-*-* | k8-*-* | k10-*-* | bobcat-*-* | jaguar*-*-* | bulldozer*-*-* | piledriver*-*-* | steamroller*-*-* | excavator*-*-* | pentium4-*-* | atom-*-* | silvermont-*-* | goldmont-*-* | core2-*-* | corei*-*-* | x86_64-*-* | nano-*-* | nehalem*-*-* | westmere*-*-* | sandybridge*-*-* | ivybridge*-*-* | haswell*-*-* | broadwell*-*-* | skylake*-*-* | kabylake*-*-*]])
 
 dnl  GMP_FAT_SUFFIX(DSTVAR, DIRECTORY)
 dnl  ---------------------------------
@@ -1754,9 +1754,9 @@ EOF
 gmp_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >&AC_FD_CC"
 if AC_TRY_EVAL(gmp_compile); then
   $NM conftest.$OBJEXT >conftest.out
-  if grep _gurkmacka conftest.out >/dev/null; then
+  if grep "[[ 	]]_gurkmacka" conftest.out >/dev/null; then
     gmp_cv_asm_underscore=yes
-  elif grep gurkmacka conftest.out >/dev/null; then
+  elif grep "[[ 	]]gurkmacka" conftest.out >/dev/null; then
     gmp_cv_asm_underscore=no
   else
     echo "configure: $NM doesn't have gurkmacka:" >&AC_FD_CC
diff --git a/source/libs/gmp/gmp-src/config.in b/source/libs/gmp/gmp-src/config.in
index 34d65a2cdaae34d022577c71c9b098c9476c22f8..448bc6fa1b98349f1dc225fe02f2f84121398139 100644
--- a/source/libs/gmp/gmp-src/config.in
+++ b/source/libs/gmp/gmp-src/config.in
@@ -511,6 +511,9 @@ see https://www.gnu.org/licenses/.
 /* Define to the sub-directory where libtool stores uninstalled libraries. */
 #undef LT_OBJDIR
 
+/* Define to 1 to disable the use of inline assembly */
+#undef NO_ASM
+
 /* Name of package */
 #undef PACKAGE
 
@@ -565,9 +568,6 @@ see https://www.gnu.org/licenses/.
 /* Version number of package */
 #undef VERSION
 
-/* Defined to 1 as per --enable-assembly */
-#undef WANT_ASSEMBLY
-
 /* Define to 1 to enable ASSERT checking, per --enable-assert */
 #undef WANT_ASSERT
 
diff --git a/source/libs/gmp/gmp-src/configgmp.guess b/source/libs/gmp/gmp-src/configgmp.guess
index b9d0c5894d53877e79ee434e5e3742770041c98e..744e11e494784fbc99f49b881f322bbe514405cf 100755
--- a/source/libs/gmp/gmp-src/configgmp.guess
+++ b/source/libs/gmp/gmp-src/configgmp.guess
@@ -762,6 +762,48 @@ i?86-*-* | amd64-*-* | x86_64-*-*)
 extern "C"
 #endif
 unsigned int cpuid (int, char *, char *, int);
+
+int
+gmp_workaround_skylake_cpuid_bug ()
+{
+  char feature_string[49];
+  char processor_name_string[49];
+  static const char *bad_cpus[] = {" G44", " G45", " G39" /* , "6600" */ };
+  int i;
+
+  /* Example strings:                                   */
+  /* "Intel(R) Pentium(R) CPU G4400 @ 3.30GHz"          */
+  /* "Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz"         */
+  /*                  ^               ^               ^ */
+  /*     0x80000002       0x80000003      0x80000004    */
+  /* We match out just the 0x80000003 part here. */
+
+  /* In their infinitive wisdom, Intel decided to use one register order for
+     the vendor string, and another for the processor name string.  We shuffle
+     things about here, rather than write a new variant of our assembly cpuid.
+  */
+
+  unsigned int eax, ebx, ecx, edx;
+  eax = CPUID (feature_string, 0x80000003);
+  ebx = ((unsigned int *)feature_string)[0];
+  edx = ((unsigned int *)feature_string)[1];
+  ecx = ((unsigned int *)feature_string)[2];
+
+  ((unsigned int *) (processor_name_string))[0] = eax;
+  ((unsigned int *) (processor_name_string))[1] = ebx;
+  ((unsigned int *) (processor_name_string))[2] = ecx;
+  ((unsigned int *) (processor_name_string))[3] = edx;
+
+  processor_name_string[16] = 0;
+
+  for (i = 0; i < sizeof (bad_cpus) / sizeof (char *); i++)
+    {
+      if (strstr (processor_name_string, bad_cpus[i]) != 0)
+	return 1;
+    }
+  return 0;
+}
+
 int
 main ()
 {
@@ -839,16 +881,19 @@ main ()
           else if (model == 0x5c) cpu_64bit = 1,            modelstr = "goldmont";   /* Goldmont */
           else if (model == 0x5e) cpu_64bit = 1, cpu_avx=1, modelstr = "skylake";    /* Skylake */
           else if (model == 0x5f) cpu_64bit = 1,            modelstr = "goldmont";   /* Goldmont */
-          else if (model == 0x8e) cpu_64bit = 1, cpu_avx=1, modelstr = "cabylake";   /* Capylake Y/U */
-          else if (model == 0x9e) cpu_64bit = 1, cpu_avx=1, modelstr = "cabylake";   /* Capylake desktop */
+          else if (model == 0x8e) cpu_64bit = 1, cpu_avx=1, modelstr = "kabylake";   /* Kabylake Y/U */
+          else if (model == 0x9e) cpu_64bit = 1, cpu_avx=1, modelstr = "kabylake";   /* Kabylake desktop */
           else                    cpu_64bit = 1,            modelstr = "nehalem";    /* default */
 
-	  if (strcmp (modelstr, "haswell") == 0)
+	  if (strcmp (modelstr, "haswell") == 0 ||
+	      strcmp (modelstr, "broadwell") == 0 ||
+	      strcmp (modelstr, "skylake") == 0)
 	    {
-	      /* Some Haswells lack BMI2.  Let them appear as Sandybridges for
-		 now.  */
+	      /* Some haswell, broadwell, skylake lack BMI2.  Let them appear
+		 as sandybridge for now.  */
 	      CPUID (feature_string, 7);
-	      if ((feature_string[0 + 8 / 8] & (1 << (8 % 8))) == 0)
+	      if ((feature_string[0 + 8 / 8] & (1 << (8 % 8))) == 0
+		  || gmp_workaround_skylake_cpuid_bug ())
 		modelstr = "sandybridge";
 	    }
 
diff --git a/source/libs/gmp/gmp-src/configgmp.sub b/source/libs/gmp/gmp-src/configgmp.sub
index f248e7170437202d297af4281e8dd3badb5a3587..6b7d04b9bb2cad175a591a7ef19f8aa0d1294038 100755
--- a/source/libs/gmp/gmp-src/configgmp.sub
+++ b/source/libs/gmp/gmp-src/configgmp.sub
@@ -102,7 +102,7 @@ itanium | itanium2)
   test_cpu=ia64 ;;
 pentium | pentiummmx | pentiumpro | pentium[234m] | k[567] | k6[23] | geode | athlon | viac3*)
   test_cpu=i386 ;;
-athlon64 | atom | silvermont | goldmont | core2 | corei* | opteron | k[89] | k10 | bobcat | jaguar* | bulldozer* | piledriver* | steamroller* | excavator* | nano | nehalem* | westmere* | sandybridge* | ivybridge* | haswell* | broadwell* | skylake* | cabylake* | knightslanding)
+athlon64 | atom | silvermont | goldmont | core2 | corei* | opteron | k[89] | k10 | bobcat | jaguar* | bulldozer* | piledriver* | steamroller* | excavator* | nano | nehalem* | westmere* | sandybridge* | ivybridge* | haswell* | broadwell* | skylake* | kabylake* | knightslanding)
   test_cpu=x86_64 ;;
 power[2-9] | power2sc)
   test_cpu=power ;;
diff --git a/source/libs/gmp/gmp-src/configure.ac b/source/libs/gmp/gmp-src/configure.ac
index 9cedfeb75c14cd5abf74cdf4c0c0ae870ce19e8c..92b29fe2d55a420e37de9238b3209a563df9794e 100644
--- a/source/libs/gmp/gmp-src/configure.ac
+++ b/source/libs/gmp/gmp-src/configure.ac
@@ -142,11 +142,6 @@ yes|no) ;;
 esac],
 [enable_assembly=yes])
 
-if test "$enable_assembly" = "yes"; then
-  AC_DEFINE(WANT_ASSEMBLY,1,
-  [Defined to 1 as per --enable-assembly])
-fi
-
 
 AC_ARG_ENABLE(fft,
 AC_HELP_STRING([--enable-fft],[enable FFTs for multiplication [default=yes]]),
@@ -625,35 +620,23 @@ case $host in
     # either enforce them, or organise to strip paths as the corresponding
     # options fail.
     case $host_cpu in
-      armv7*)
-	path="arm/v6t2 arm/v6 arm/v5 arm"
-	gcc_cflags_arch="-march=armv7-a"
-	;;
-      armv6t2*)
-	path="arm/v6t2 arm/v6 arm/v5 arm"
-	gcc_cflags_arch="-march=armv6t2"
-	;;
-      armv6*)
-	path="arm/v6 arm/v5 arm"
-	gcc_cflags_arch="-march=armv6"
-	;;
-      armsa1 | arm9tdmi | armv4*)
+      armsa1 | arm7t* | arm9t* | armv4t*)
 	path="arm"
 	gcc_cflags_arch="-march=armv4"
 	;;
-      armxscale | arm9te | arm10 | armv5*)
+      armxscale | arm7ej | arm9te | arm9e* | arm10* | armv5*)
 	path="arm/v5 arm"
 	gcc_cflags_arch="-march=armv5"
 	;;
-      arm11mpcore | arm1136 | arm1176*)
-	path="arm/v6 arm/v5 arm"
-	gcc_cflags_arch="-march=armv6"
-	;;
-      arm1156)
+      arm1156 | armv6t2*)
 	path="arm/v6t2 arm/v6 arm/v5 arm"
 	gcc_cflags_arch="-march=armv6t2"
 	;;
-      armcortexa5)
+      arm11* | armv6*)
+	path="arm/v6 arm/v5 arm"
+	gcc_cflags_arch="-march=armv6"
+	;;
+      armcortexa5 | armv7*)
 	path="arm/v6t2 arm/v6 arm/v5 arm"
 	gcc_cflags_arch="-march=armv7-a"
 	;;
@@ -703,6 +686,8 @@ case $host in
 	;;
       *)
 	path="arm"
+	gcc_cflags_arch="-march=armv4"
+	GMP_DEFINE_RAW(["define(<NOTHUMB>,1)"])
 	;;
     esac
     ;;
@@ -1800,7 +1785,7 @@ case $host in
 	path_64="x86_64/coreibwl x86_64/coreihwl x86_64/coreisbr x86_64/coreinhm x86_64/core2 x86_64"
 	# extra_functions_64="missing"	 # enable for bmi2/adx simulation
 	;;
-      skylake | skylakenoavx | cabylake | cabylakenoavx)
+      skylake | skylakenoavx | kabylake | kabylakenoavx)
 	gcc_cflags_cpu="-mtune=skylake -mtune=broadwell -mtune=corei7 -mtune=core2 -mtune=k8"
 	# Don't pass -march=skylake for now as then some compilers emit AVX512.
 	gcc_cflags_arch="-march=broadwell -march=corei7 -march=core2 -march=core2~-mno-sse2 -march=k8 -march=k8~-mno-sse2"
@@ -2470,7 +2455,7 @@ esac
 
 if test "$enable_assembly" = "no"; then
   path="generic"
-  CFLAGS="$CFLAGS -DNO_ASM"
+  AC_DEFINE([NO_ASM],1,[Define to 1 to disable the use of inline assembly])
 #  for abi in $abilist; do
 #    eval unset "path_\$abi"
 #    eval gcc_${abi}_cflags=\"\$gcc_${abi}_cflags -DNO_ASM\"
diff --git a/source/libs/gmp/gmp-src/gmp-h.in b/source/libs/gmp/gmp-src/gmp-h.in
index 8329e78c15acb42ca4467895d253dab149f0f647..1c836e9d5000bd96cf070de4f49a912994a4ddc9 100644
--- a/source/libs/gmp/gmp-src/gmp-h.in
+++ b/source/libs/gmp/gmp-src/gmp-h.in
@@ -1,6 +1,6 @@
 /* Definitions for GNU multiple precision functions.   -*- mode: c -*-
 
-Copyright 1991, 1993-1997, 1999-2015 Free Software Foundation, Inc.
+Copyright 1991, 1993-1997, 1999-2016 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -2326,7 +2326,7 @@ enum
 /* Major version number is the value of __GNU_MP__ too, above and in mp.h. */
 #define __GNU_MP_VERSION            6
 #define __GNU_MP_VERSION_MINOR      1
-#define __GNU_MP_VERSION_PATCHLEVEL 0
+#define __GNU_MP_VERSION_PATCHLEVEL 1
 #define __GNU_MP_RELEASE (__GNU_MP_VERSION * 10000 + __GNU_MP_VERSION_MINOR * 100 + __GNU_MP_VERSION_PATCHLEVEL)
 
 #define __GMP_H__
diff --git a/source/libs/gmp/gmp-src/gmp-impl.h b/source/libs/gmp/gmp-src/gmp-impl.h
index 24214a604780525d375800b7c1f71883b9335b73..6987581049cf28c6cafd03c3c900ad4968248b16 100644
--- a/source/libs/gmp/gmp-src/gmp-impl.h
+++ b/source/libs/gmp/gmp-src/gmp-impl.h
@@ -1273,7 +1273,9 @@ __GMP_DECLSPEC extern gmp_randstate_t  __gmp_rands;
 #endif
 #define BELOW_THRESHOLD(size,thresh)  (! ABOVE_THRESHOLD (size, thresh))
 
-#define MPN_TOOM22_MUL_MINSIZE    4
+/* The minimal supported value for Toom22 depends also on Toom32 and
+   Toom42 implementations. */
+#define MPN_TOOM22_MUL_MINSIZE    6
 #define MPN_TOOM2_SQR_MINSIZE     4
 
 #define MPN_TOOM33_MUL_MINSIZE   17
@@ -2293,8 +2295,8 @@ __GMP_DECLSPEC mp_limb_t gmp_primesieve (mp_ptr, mp_limb_t);
 
 struct fft_table_nk
 {
-  unsigned int n:27;
-  unsigned int k:5;
+  gmp_uint_least32_t n:27;
+  gmp_uint_least32_t k:5;
 };
 
 #ifndef FFT_TABLE_ATTRS
diff --git a/source/libs/gmp/gmp-src/mpn/arm/aorslsh1_n.asm b/source/libs/gmp/gmp-src/mpn/arm/aorslsh1_n.asm
index 1cbd4ba1af4667f8fdf03f78c85776c3961f1622..09b1662b708c2e7b6247905c18d03262d5f143bc 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/aorslsh1_n.asm
+++ b/source/libs/gmp/gmp-src/mpn/arm/aorslsh1_n.asm
@@ -163,5 +163,5 @@ L(rt1):	mov	r14, r12
 	REVCY(r12)
 L(rt0):	RETVAL(	r14)
 	pop	{r4-r10r11, r14}
-	bx	r14
+	ret	r14
 EPILOGUE()
diff --git a/source/libs/gmp/gmp-src/mpn/arm/arm-defs.m4 b/source/libs/gmp/gmp-src/mpn/arm/arm-defs.m4
index 6ca964a2459a7c459bed0a2347616285df77ea92..371d8ea0f4d77d9453628661efa47c5a649d4e4e 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/arm-defs.m4
+++ b/source/libs/gmp/gmp-src/mpn/arm/arm-defs.m4
@@ -84,6 +84,9 @@ L(ptr'lea_num`):	.word	GSYM_PREFIX`'$2')
 ')dnl
 ')
 
+define(`ret',`ifdef(`NOTHUMB',`mov	pc, ',`bx')')
+
+
 define(`EPILOGUE_cpu',
 `lea_list
 	SIZE(`$1',.-`$1')')
diff --git a/source/libs/gmp/gmp-src/mpn/arm/bdiv_dbm1c.asm b/source/libs/gmp/gmp-src/mpn/arm/bdiv_dbm1c.asm
index ec3de50e8e2170d61cade58f2071af66f37d5e05..48057559c9bdba87f1e44425cdbfa589fe136904 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/bdiv_dbm1c.asm
+++ b/source/libs/gmp/gmp-src/mpn/arm/bdiv_dbm1c.asm
@@ -109,5 +109,5 @@ L(wd1):	subs	r5, r5, r8
 	str	r5, [qp]
 	sbc	r0, r5, r12
 	pop	{r4, r5, r6, r7, r8}
-	bx	lr
+	ret	lr
 EPILOGUE()
diff --git a/source/libs/gmp/gmp-src/mpn/arm/cnd_aors_n.asm b/source/libs/gmp/gmp-src/mpn/arm/cnd_aors_n.asm
index e8eb60983aff4ecc1a1effe4c1dc49916a237ece..f0399e29dab222905fb8805290aca68f3d3b04cb 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/cnd_aors_n.asm
+++ b/source/libs/gmp/gmp-src/mpn/arm/cnd_aors_n.asm
@@ -130,5 +130,5 @@ L(top):	ldm	vp!, {r4,r5,r6,r7}
 
 L(end):	RETVAL
 	pop	{r4-r11}
-	bx	r14
+	ret	r14
 EPILOGUE()
diff --git a/source/libs/gmp/gmp-src/mpn/arm/com.asm b/source/libs/gmp/gmp-src/mpn/arm/com.asm
index 42f8e3cbbe3d780c3b637e1b5e4f6a3f3e3335bd..57db9af0f4d8b40faea6b31e3ddfba081d51b5da 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/com.asm
+++ b/source/libs/gmp/gmp-src/mpn/arm/com.asm
@@ -71,5 +71,5 @@ L(top):	ldmia	up!, { r3, r8, r9, r12 }	C load 4 limbs
 	bne	L(top)
 
 	ldmfd	sp!, { r7, r8, r9 }		C restore regs from stack
-L(rtn):	bx	lr
+L(rtn):	ret	lr
 EPILOGUE()
diff --git a/source/libs/gmp/gmp-src/mpn/arm/copyd.asm b/source/libs/gmp/gmp-src/mpn/arm/copyd.asm
index 3ea2035099d43ecf5ab8c56e30efb8fa379d25b2..938b1dcb013b6da2c08ad2ad10c80765b5a691d6 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/copyd.asm
+++ b/source/libs/gmp/gmp-src/mpn/arm/copyd.asm
@@ -80,5 +80,5 @@ L(top):	subs	n, n, #4
 
 L(end):	stmda	rp, { r3,r4,r5,r12 }
 	pop	{ r4-r5 }
-L(rtn):	bx	lr
+L(rtn):	ret	lr
 EPILOGUE()
diff --git a/source/libs/gmp/gmp-src/mpn/arm/copyi.asm b/source/libs/gmp/gmp-src/mpn/arm/copyi.asm
index fa454702c14e9144513fac79c6c83a2637c0be0c..0dc4e597111b15a20b4072d1cc212045f32555dd 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/copyi.asm
+++ b/source/libs/gmp/gmp-src/mpn/arm/copyi.asm
@@ -75,5 +75,5 @@ L(top):	subs	n, n, #4
 
 L(end):	stm	rp, { r3,r4,r5,r12 }
 	pop	{ r4-r5 }
-L(rtn):	bx	lr
+L(rtn):	ret	lr
 EPILOGUE()
diff --git a/source/libs/gmp/gmp-src/mpn/arm/dive_1.asm b/source/libs/gmp/gmp-src/mpn/arm/dive_1.asm
index ccceb3c3cc3d353cbffa3f5dc04da8a2f7ea3784..f9921e55ea17f84279b3c9d73ec841bd72a9fb99 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/dive_1.asm
+++ b/source/libs/gmp/gmp-src/mpn/arm/dive_1.asm
@@ -112,7 +112,7 @@ L(end):	sbc	cy, r5, cy
 	mul	r9, r4, cy
 	str	r9, [rp]
 	pop	{r4-r9}
-	bx	r14
+	ret	r14
 
 L(unnorm):
 	rsb	tnc, cnt, #32
@@ -136,7 +136,7 @@ L(edu):	sbc	cy, r5, cy
 	mul	r9, r4, cy
 	str	r9, [rp]
 	pop	{r4-r9}
-	bx	r14
+	ret	r14
 EPILOGUE()
 
 	RODATA
diff --git a/source/libs/gmp/gmp-src/mpn/arm/invert_limb.asm b/source/libs/gmp/gmp-src/mpn/arm/invert_limb.asm
index 06ce1467ced78b5a0eef88b2abd20e9499bbaf84..c969ed525c48c6c1c9d2f1d2ac3cd2d5a25d4529 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/invert_limb.asm
+++ b/source/libs/gmp/gmp-src/mpn/arm/invert_limb.asm
@@ -52,7 +52,7 @@ PROLOGUE(mpn_invert_limb)
 	adds	r1, r12, r0
 	adc	r3, r3, r0
 	rsb	r0, r3, r2
-	bx	lr
+	ret	lr
 EPILOGUE()
 
 	RODATA
diff --git a/source/libs/gmp/gmp-src/mpn/arm/logops_n.asm b/source/libs/gmp/gmp-src/mpn/arm/logops_n.asm
index 5a61683fc2e9f9253696080292feeb933c651dd2..02ebbf3b9ce688b5e392d7b23dd2f2e50e1eb07a 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/logops_n.asm
+++ b/source/libs/gmp/gmp-src/mpn/arm/logops_n.asm
@@ -135,5 +135,5 @@ L(mid):	sub	n, n, #4
 	pop	{ r4, r5, r6, r7 }	C popping r8-r10 here strangely fails
 
 L(rtn):	pop	{ r8, r9, r10 }
-	bx	r14
+	ret	r14
 EPILOGUE()
diff --git a/source/libs/gmp/gmp-src/mpn/arm/lshift.asm b/source/libs/gmp/gmp-src/mpn/arm/lshift.asm
index 9f777eb4dd8f85706faa66e3f7eb41c39a3e34d0..9e828423b393042e3fb140df4d61ccbd868bcdc2 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/lshift.asm
+++ b/source/libs/gmp/gmp-src/mpn/arm/lshift.asm
@@ -84,5 +84,5 @@ L(end):	orr	r7, r7, r6, lsr tnc
 L(1):	str	r7, [rp, #-4]
 	mov	r0, r4, lsr tnc
 	pop	{r4, r6, r7, r8}
-	bx	r14
+	ret	r14
 EPILOGUE()
diff --git a/source/libs/gmp/gmp-src/mpn/arm/lshiftc.asm b/source/libs/gmp/gmp-src/mpn/arm/lshiftc.asm
index 5f3d6e3f5b7598f813a040d6cea282fdad293e13..1a2fa682ae649ab933bec1f0c7ad1a1826000897 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/lshiftc.asm
+++ b/source/libs/gmp/gmp-src/mpn/arm/lshiftc.asm
@@ -91,5 +91,5 @@ L(1):	mvn	r6, #0
 	str	r7, [rp, #-4]
 	mov	r0, r4, lsr tnc
 	pop	{r4, r6, r7, r8}
-	bx	r14
+	ret	r14
 EPILOGUE()
diff --git a/source/libs/gmp/gmp-src/mpn/arm/mod_34lsub1.asm b/source/libs/gmp/gmp-src/mpn/arm/mod_34lsub1.asm
index ba3c06d8db1089963628d74e11d1dcb193c3de88..0dace666f6c1c941dce8f3f4a71e8b0c05d13caa 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/mod_34lsub1.asm
+++ b/source/libs/gmp/gmp-src/mpn/arm/mod_34lsub1.asm
@@ -106,7 +106,7 @@ L(sum2):
 	add	r0, r0, r12, lsr #8
 
 	pop	{ r4, r5, r6, r7 }
-	bx	lr
+	ret	lr
 
 L(le2):	cmn	n, #1
 	bne	L(1)
@@ -117,5 +117,5 @@ L(1):	ldr	r2, [ap]
 	bic	r0, r2, #0xff000000
 	add	r0, r0, r2, lsr #24
 	pop	{ r4, r5, r6, r7 }
-	bx	lr
+	ret	lr
 EPILOGUE()
diff --git a/source/libs/gmp/gmp-src/mpn/arm/mode1o.asm b/source/libs/gmp/gmp-src/mpn/arm/mode1o.asm
index 5e0f78fc8f58a2332e47d23af93ef208e931cfc4..83a33aa650d91074b57ff05477eb9b930ed33e8b 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/mode1o.asm
+++ b/source/libs/gmp/gmp-src/mpn/arm/mode1o.asm
@@ -88,5 +88,5 @@ L(end):	sbcs	cy, r5, cy
 	addcc	r0, r0, #1
 
 	ldmfd	sp!, {r4, r5}
-	bx	r14
+	ret	r14
 EPILOGUE()
diff --git a/source/libs/gmp/gmp-src/mpn/arm/rsh1aors_n.asm b/source/libs/gmp/gmp-src/mpn/arm/rsh1aors_n.asm
index 95c1f79ad9f999c126f331a394dff8b1ef534153..454cf5605d6eb7c57d75eafe7295efc47df8ddbd 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/rsh1aors_n.asm
+++ b/source/libs/gmp/gmp-src/mpn/arm/rsh1aors_n.asm
@@ -120,5 +120,5 @@ L(e1):	RSTCY(	r12, r1)
 	str	r4, [rp, #0]
 	mov	r0, r11
 	pop	{r4-r11}
-	bx	r14
+	ret	r14
 EPILOGUE()
diff --git a/source/libs/gmp/gmp-src/mpn/arm/rshift.asm b/source/libs/gmp/gmp-src/mpn/arm/rshift.asm
index 84728d038a774ae2818629a15a38100ad68b4add..dbe9f93e70a8abff52083882824d6ed5198e5e24 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/rshift.asm
+++ b/source/libs/gmp/gmp-src/mpn/arm/rshift.asm
@@ -82,5 +82,5 @@ L(end):	orr	r7, r7, r6, lsl tnc
 L(1):	str	r7, [rp]
 	mov	r0, r4, lsl tnc
 	pop	{r4, r6, r7, r8}
-	bx	r14
+	ret	r14
 EPILOGUE()
diff --git a/source/libs/gmp/gmp-src/mpn/arm/sec_tabselect.asm b/source/libs/gmp/gmp-src/mpn/arm/sec_tabselect.asm
index 8cf937a0917f4593c5badc2eec83084fd6252d6a..c2b054971734e746e1627f35192cf476a52ff8d6 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/sec_tabselect.asm
+++ b/source/libs/gmp/gmp-src/mpn/arm/sec_tabselect.asm
@@ -109,7 +109,7 @@ L(tp2):	subs	c, c, #1
 	bge	L(tp2)
 	stmia	rp, {r8,r9}
 	pop	{r4-r11, r14}
-	bx	lr
+	ret	lr
 
 L(n2):	cmp	j, #-2
 	bne	L(n1)
@@ -127,5 +127,5 @@ L(tp1):	subs	c, c, #1
 	bge	L(tp1)
 	str	r8, [rp]
 L(n1):	pop	{r4-r11, r14}
-	bx	lr
+	ret	lr
 EPILOGUE()
diff --git a/source/libs/gmp/gmp-src/mpn/arm/udiv.asm b/source/libs/gmp/gmp-src/mpn/arm/udiv.asm
index 8d441c74edd37cf1bcb065aebb7ad3d0e214cddb..bcf66ef0edb88c0e5b4dc745de5bb1c4bdd6e669 100644
--- a/source/libs/gmp/gmp-src/mpn/arm/udiv.asm
+++ b/source/libs/gmp/gmp-src/mpn/arm/udiv.asm
@@ -61,7 +61,7 @@ L(oop):	divstep(n1,n0,d)
 
 	str	n1, [rem_ptr]		C store remainder
 	adc	r0, n0, n0		C quotient: add last carry from divstep
-	bx	lr
+	ret	lr
 
 L(_large_divisor):
 	stmfd	sp!, { r8, lr }
diff --git a/source/libs/gmp/gmp-src/mpn/generic/trialdiv.c b/source/libs/gmp/gmp-src/mpn/generic/trialdiv.c
index 09cecfd410874814ebc8087c92293759a5a57e52..6e83c996fed659a3257c7f531cb8884a3339a470 100644
--- a/source/libs/gmp/gmp-src/mpn/generic/trialdiv.c
+++ b/source/libs/gmp/gmp-src/mpn/generic/trialdiv.c
@@ -65,8 +65,8 @@ struct gmp_primes_dtab {
 struct gmp_primes_ptab {
   mp_limb_t ppp;	/* primes, multiplied together */
   mp_limb_t cps[7];	/* ppp values pre-computed for mpn_mod_1s_4p */
-  unsigned int idx:24;	/* index of  first primes in dtab */
-  unsigned int np :8;	/* number of primes related to this entry */
+  gmp_uint_least32_t idx:24;	/* index of  first primes in dtab */
+  gmp_uint_least32_t np :8;	/* number of primes related to this entry */
 };
 
 
diff --git a/source/libs/gmp/gmp-src/mpn/x86_64/coreibwl/mul_basecase.asm b/source/libs/gmp/gmp-src/mpn/x86_64/coreibwl/mul_basecase.asm
index 6365d10a18569ce5f4435584dee79c8b0b5e7723..50f3ce5877e651e647825c593c5f393e5b9464c9 100644
--- a/source/libs/gmp/gmp-src/mpn/x86_64/coreibwl/mul_basecase.asm
+++ b/source/libs/gmp/gmp-src/mpn/x86_64/coreibwl/mul_basecase.asm
@@ -94,6 +94,7 @@ IFDOS(`	mov	56(%rsp), %r8d	')
 
 L(s11):	mov	%rax, (rp)
 	mov	%r9, 8(rp)
+	FUNC_EXIT()
 	ret
 
 L(s2x):	cmp	$2, vn
@@ -105,6 +106,7 @@ L(s21):	add	%r8, %r9
 	mov	%rax, (rp)
 	mov	%r9, 8(rp)
 	mov	%r10, 16(rp)
+	FUNC_EXIT()
 	ret
 
 L(s22):	add	%r8, %r9		C 1
@@ -121,6 +123,7 @@ L(s22):	add	%r8, %r9		C 1
 	mov	%r9, 8(rp)
 	mov	%r10, 16(rp)
 	mov	%rdx, 24(rp)
+	FUNC_EXIT()
 	ret
 
 	ALIGN(16)
@@ -294,6 +297,7 @@ L(done):
 	pop	%r12
 	pop	%rbp
 	pop	%rbx
+	FUNC_EXIT()
 	ret
 
 L(f2):
diff --git a/source/libs/gmp/gmp-src/mpn/x86_64/fat/fat.c b/source/libs/gmp/gmp-src/mpn/x86_64/fat/fat.c
index 30cd2104ff50c9bc3d16c11e81fe52b91a4e5de0..b8482fec7439b1a6041cc20451f49fa4c04b878a 100644
--- a/source/libs/gmp/gmp-src/mpn/x86_64/fat/fat.c
+++ b/source/libs/gmp/gmp-src/mpn/x86_64/fat/fat.c
@@ -206,6 +206,49 @@ int __gmpn_cpuvec_initialized = 0;
    asm routines only operate correctly up to their own defined threshold,
    not an arbitrary value.  */
 
+static int
+gmp_workaround_skylake_cpuid_bug ()
+{
+  char feature_string[49];
+  char processor_name_string[49];
+  static const char *bad_cpus[] = {" G44", " G45", " G39" /* , "6600" */ };
+  int i;
+
+  /* Example strings:                                   */
+  /* "Intel(R) Pentium(R) CPU G4400 @ 3.30GHz"          */
+  /* "Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz"         */
+  /*                  ^               ^               ^ */
+  /*     0x80000002       0x80000003      0x80000004    */
+  /* We match out just the 0x80000003 part here. */
+
+  /* In their infinitive wisdom, Intel decided to use one register order for
+     the vendor string, and another for the processor name string.  We shuffle
+     things about here, rather than write a new variant of our assembly cpuid.
+  */
+
+  unsigned int eax, ebx, ecx, edx;
+  eax = __gmpn_cpuid (feature_string, 0x80000003);
+  ebx = ((unsigned int *)feature_string)[0];
+  edx = ((unsigned int *)feature_string)[1];
+  ecx = ((unsigned int *)feature_string)[2];
+
+  ((unsigned int *) (processor_name_string))[0] = eax;
+  ((unsigned int *) (processor_name_string))[1] = ebx;
+  ((unsigned int *) (processor_name_string))[2] = ecx;
+  ((unsigned int *) (processor_name_string))[3] = edx;
+
+  processor_name_string[16] = 0;
+
+  for (i = 0; i < sizeof (bad_cpus) / sizeof (char *); i++)
+    {
+      if (strstr (processor_name_string, bad_cpus[i]) != 0)
+	return 1;
+    }
+  return 0;
+}
+
+enum {BMI2_BIT = 8};
+
 void
 __gmpn_cpuvec_init (void)
 {
@@ -311,8 +354,9 @@ __gmpn_cpuvec_init (void)
 	      /* Some Haswells lack BMI2.  Let them appear as Sandybridges for
 		 now.  */
 	      __gmpn_cpuid (dummy_string, 7);
-	      if ((dummy_string[0 + 8 / 8] & (1 << (8 % 8))) != 0)
-		CPUVEC_SETUP_coreihwl;
+	      if ((dummy_string[0 + BMI2_BIT / 8] & (1 << (BMI2_BIT % 8))) == 0)
+		break;
+	      CPUVEC_SETUP_coreihwl;
 	      break;
 	    case 0x3d:		/* Broadwell */
 	    case 0x47:		/* Broadwell */
@@ -321,17 +365,23 @@ __gmpn_cpuvec_init (void)
 	      CPUVEC_SETUP_core2;
 	      CPUVEC_SETUP_coreinhm;
 	      CPUVEC_SETUP_coreisbr;
+	      if ((dummy_string[0 + BMI2_BIT / 8] & (1 << (BMI2_BIT % 8))) == 0)
+		break;
 	      CPUVEC_SETUP_coreihwl;
 	      CPUVEC_SETUP_coreibwl;
 	      break;
 	    case 0x4e:		/* Skylake client */
 	    case 0x55:		/* Skylake server */
 	    case 0x5e:		/* Skylake */
-	    case 0x8e:		/* Cabylake */
-	    case 0x9e:		/* Cabylake */
+	    case 0x8e:		/* Kabylake */
+	    case 0x9e:		/* Kabylake */
 	      CPUVEC_SETUP_core2;
 	      CPUVEC_SETUP_coreinhm;
 	      CPUVEC_SETUP_coreisbr;
+	      if ((dummy_string[0 + BMI2_BIT / 8] & (1 << (BMI2_BIT % 8))) == 0)
+		break;
+	      if (gmp_workaround_skylake_cpuid_bug ())
+		break;
 	      CPUVEC_SETUP_coreihwl;
 	      CPUVEC_SETUP_coreibwl;
 	      CPUVEC_SETUP_skylake;
diff --git a/source/libs/gmp/gmp-src/printf/doprnt.c b/source/libs/gmp/gmp-src/printf/doprnt.c
index 5220feee206601ed31d282bac53472682f00da10..f3e3e4e1b7c42e6b82e3873abdd7b868a9db355d 100644
--- a/source/libs/gmp/gmp-src/printf/doprnt.c
+++ b/source/libs/gmp/gmp-src/printf/doprnt.c
@@ -160,7 +160,7 @@ __gmp_doprnt (const struct doprnt_funs_t *funs, void *data,
 	      const char *orig_fmt, va_list orig_ap)
 {
   va_list  ap, this_ap, last_ap;
-  size_t   alloc_fmt_size;
+  size_t   alloc_fmt_size, orig_fmt_size;
   char     *fmt, *alloc_fmt, *last_fmt, *this_fmt, *gmp_str;
   int      retval = 0;
   int      type, fchar, *value, seen_precision;
@@ -180,7 +180,7 @@ __gmp_doprnt (const struct doprnt_funs_t *funs, void *data,
      piece can be null-terminated.  We're not going to be very fast here, so
      use __gmp_allocate_func rather than TMP_ALLOC, to avoid overflowing the
      stack if a long output string is given.  */
-  alloc_fmt_size = strlen (orig_fmt) + 1;
+  alloc_fmt_size = orig_fmt_size = strlen (orig_fmt) + 1;
 #if _LONG_LONG_LIMB
   /* for a long long limb we change %Mx to %llx, so could need an extra 1
      char for every 3 existing */
@@ -188,7 +188,7 @@ __gmp_doprnt (const struct doprnt_funs_t *funs, void *data,
 #endif
   alloc_fmt = __GMP_ALLOCATE_FUNC_TYPE (alloc_fmt_size, char);
   fmt = alloc_fmt;
-  memcpy (fmt, orig_fmt, alloc_fmt_size);
+  memcpy (fmt, orig_fmt, orig_fmt_size);
 
   /* last_fmt and last_ap are just after the last output, and hence where
      the next output will begin, when that's done */
diff --git a/source/libs/gmp/native/configure b/source/libs/gmp/native/configure
index 53c04ad3a5faee275c934f6bb5de4bbe5002c9bb..a73b3119efe10065fcd0f72a7e7abc77b10bfd41 100755
--- a/source/libs/gmp/native/configure
+++ b/source/libs/gmp/native/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for gmp native 6.1.0.
+# Generated by GNU Autoconf 2.69 for gmp native 6.1.1.
 #
 # Report bugs to <tex-k@tug.org>.
 #
@@ -579,8 +579,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='gmp native'
 PACKAGE_TARNAME='gmp-native'
-PACKAGE_VERSION='6.1.0'
-PACKAGE_STRING='gmp native 6.1.0'
+PACKAGE_VERSION='6.1.1'
+PACKAGE_STRING='gmp native 6.1.1'
 PACKAGE_BUGREPORT='tex-k@tug.org'
 PACKAGE_URL=''
 
@@ -1234,7 +1234,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures gmp native 6.1.0 to adapt to many kinds of systems.
+\`configure' configures gmp native 6.1.1 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1300,7 +1300,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of gmp native 6.1.0:";;
+     short | recursive ) echo "Configuration of gmp native 6.1.1:";;
    esac
   cat <<\_ACEOF
 
@@ -1396,7 +1396,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-gmp native configure 6.1.0
+gmp native configure 6.1.1
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1497,7 +1497,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by gmp native $as_me 6.1.0, which was
+It was created by gmp native $as_me 6.1.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3420,7 +3420,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='gmp-native'
- VERSION='6.1.0'
+ VERSION='6.1.1'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -4974,7 +4974,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by gmp native $as_me 6.1.0, which was
+This file was extended by gmp native $as_me 6.1.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5040,7 +5040,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-gmp native config.status 6.1.0
+gmp native config.status 6.1.1
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/source/libs/gmp/version.ac b/source/libs/gmp/version.ac
index 306cacde5bcb46be17b2559d07c598b3e53eedce..792ff0fa667a4617a0d6d67662125ee05eaecf9a 100644
--- a/source/libs/gmp/version.ac
+++ b/source/libs/gmp/version.ac
@@ -8,4 +8,4 @@ dnl
 dnl --------------------------------------------------------
 dnl
 dnl  m4-include this file to define the current gmp version
-m4_define([gmp_version], [6.1.0])
+m4_define([gmp_version], [6.1.1])
diff --git a/source/libs/poppler/ChangeLog b/source/libs/poppler/ChangeLog
index f8d652f6a8552f336d753de141c0d46688145470..d3f0c47795797b7bb038b55aca84dcbfd3c9fda2 100644
--- a/source/libs/poppler/ChangeLog
+++ b/source/libs/poppler/ChangeLog
@@ -1,3 +1,8 @@
+2016-06-18  Akira Kakuto  <kakuto@fuk.kindai.ac.jp>
+
+	Import poppler-0.45.0.
+	* version.ac, configure.ac, config.h.in, Makefile.am: Adjust.
+
 2016-05-22  Akira Kakuto  <kakuto@fuk.kindai.ac.jp>
 
 	Import poppler-0.44.0.
diff --git a/source/libs/poppler/Makefile.am b/source/libs/poppler/Makefile.am
index 46037db59ed71dd077f9ba92d5d123d33a34556d..69998a81d84170def608ba8df18faf8db9c99a5b 100644
--- a/source/libs/poppler/Makefile.am
+++ b/source/libs/poppler/Makefile.am
@@ -41,6 +41,7 @@ nodist_libpoppler_a_SOURCES = \
 
 goo_libGoo_a_sources = \
 	@POPPLER_TREE@/goo/gfile.cc \
+	@POPPLER_TREE@/goo/glibc.cc \
 	@POPPLER_TREE@/goo/gmem.cc \
 	@POPPLER_TREE@/goo/gmempp.cc \
 	@POPPLER_TREE@/goo/grandom.cc \
diff --git a/source/libs/poppler/Makefile.in b/source/libs/poppler/Makefile.in
index 0c7928604cd93cc6fab75d53a64256300cd3eca0..bf99ea5f586b27261f62b11f01d808f41cd11aff 100644
--- a/source/libs/poppler/Makefile.in
+++ b/source/libs/poppler/Makefile.in
@@ -115,6 +115,7 @@ libpoppler_a_AR = $(AR) $(ARFLAGS)
 libpoppler_a_LIBADD =
 am__dirstamp = $(am__leading_dot)dirstamp
 am__objects_1 = @POPPLER_TREE@/goo/gfile.$(OBJEXT) \
+	@POPPLER_TREE@/goo/glibc.$(OBJEXT) \
 	@POPPLER_TREE@/goo/gmem.$(OBJEXT) \
 	@POPPLER_TREE@/goo/gmempp.$(OBJEXT) \
 	@POPPLER_TREE@/goo/grandom.$(OBJEXT) \
@@ -451,6 +452,7 @@ nodist_libpoppler_a_SOURCES = \
 
 goo_libGoo_a_sources = \
 	@POPPLER_TREE@/goo/gfile.cc \
+	@POPPLER_TREE@/goo/glibc.cc \
 	@POPPLER_TREE@/goo/gmem.cc \
 	@POPPLER_TREE@/goo/gmempp.cc \
 	@POPPLER_TREE@/goo/grandom.cc \
@@ -617,6 +619,9 @@ clean-noinstLIBRARIES:
 @POPPLER_TREE@/goo/gfile.$(OBJEXT):  \
 	@POPPLER_TREE@/goo/$(am__dirstamp) \
 	@POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp)
+@POPPLER_TREE@/goo/glibc.$(OBJEXT):  \
+	@POPPLER_TREE@/goo/$(am__dirstamp) \
+	@POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp)
 @POPPLER_TREE@/goo/gmem.$(OBJEXT): @POPPLER_TREE@/goo/$(am__dirstamp) \
 	@POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp)
 @POPPLER_TREE@/goo/gmempp.$(OBJEXT):  \
@@ -889,6 +894,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/GooString.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/GooTimer.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/gfile.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/glibc.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/gmem.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/gmempp.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/grandom.Po@am__quote@
diff --git a/source/libs/poppler/config.h.in b/source/libs/poppler/config.h.in
index 94f471a34b72e462c3a951e6e7fe240c175349c9..87716071b360a34544c65b104919afddf164ae10 100644
--- a/source/libs/poppler/config.h.in
+++ b/source/libs/poppler/config.h.in
@@ -63,6 +63,9 @@
 /* Define to 1 if you have the <sys/types.h> header file. */
 #undef HAVE_SYS_TYPES_H
 
+/* Define to 1 if you have the `timegm' function. */
+#undef HAVE_TIMEGM
+
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
diff --git a/source/libs/poppler/configure b/source/libs/poppler/configure
index d1b7f4382570531eac26ad2e00d2db44a56e8258..169a6ef6ab425457473ca94c1e41f99c8aa13cd2 100755
--- a/source/libs/poppler/configure
+++ b/source/libs/poppler/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for poppler (TeX Live) 0.44.0.
+# Generated by GNU Autoconf 2.69 for poppler (TeX Live) 0.45.0.
 #
 # Report bugs to <tex-k@tug.org>.
 #
@@ -580,8 +580,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='poppler (TeX Live)'
 PACKAGE_TARNAME='poppler--tex-live-'
-PACKAGE_VERSION='0.44.0'
-PACKAGE_STRING='poppler (TeX Live) 0.44.0'
+PACKAGE_VERSION='0.45.0'
+PACKAGE_STRING='poppler (TeX Live) 0.45.0'
 PACKAGE_BUGREPORT='tex-k@tug.org'
 PACKAGE_URL=''
 
@@ -1306,7 +1306,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures poppler (TeX Live) 0.44.0 to adapt to many kinds of systems.
+\`configure' configures poppler (TeX Live) 0.45.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1373,7 +1373,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of poppler (TeX Live) 0.44.0:";;
+     short | recursive ) echo "Configuration of poppler (TeX Live) 0.45.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1486,7 +1486,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-poppler (TeX Live) configure 0.44.0
+poppler (TeX Live) configure 0.45.0
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2076,7 +2076,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by poppler (TeX Live) $as_me 0.44.0, which was
+It was created by poppler (TeX Live) $as_me 0.45.0, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3999,7 +3999,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='poppler--tex-live-'
- VERSION='0.44.0'
+ VERSION='0.45.0'
 
 
 # Some tools Automake needs.
@@ -6203,7 +6203,7 @@ fi
 
 
 
-for ac_func in gettimeofday gmtime_r mkstemp popen rand_r
+for ac_func in gettimeofday gmtime_r mkstemp popen rand_r timegm
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -6578,7 +6578,7 @@ ac_config_headers="$ac_config_headers poppler-config.h:poppler-src/poppler/poppl
 
 
 cat >>confdefs.h <<_ACEOF
-#define POPPLER_VERSION "0.44.0"
+#define POPPLER_VERSION "0.45.0"
 _ACEOF
 
 
@@ -7272,7 +7272,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by poppler (TeX Live) $as_me 0.44.0, which was
+This file was extended by poppler (TeX Live) $as_me 0.45.0, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -7338,7 +7338,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-poppler (TeX Live) config.status 0.44.0
+poppler (TeX Live) config.status 0.45.0
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/source/libs/poppler/configure.ac b/source/libs/poppler/configure.ac
index eb9f94de1db6e1d15c1ecd3fc55bc5fede97b2be..b776063c18b5956d2046d539a10908f471c5b1e8 100644
--- a/source/libs/poppler/configure.ac
+++ b/source/libs/poppler/configure.ac
@@ -70,7 +70,7 @@ AC_HEADER_DIRENT
 
 dnl **** Checks for library functions ****
 
-AC_CHECK_FUNCS([gettimeofday gmtime_r mkstemp popen rand_r])
+AC_CHECK_FUNCS([gettimeofday gmtime_r mkstemp popen rand_r timegm])
 AC_SYS_LARGEFILE
 AC_FUNC_FSEEKO
 AC_CHECK_FUNC([ftell64], [AC_CHECK_FUNCS([fseek64])])
diff --git a/source/libs/poppler/poppler-PATCHES/ChangeLog b/source/libs/poppler/poppler-PATCHES/ChangeLog
index fc997a9565bb04100726d517f4500c7881138384..df5af13901f424418fe712cc15b91fc6d5fcac5f 100644
--- a/source/libs/poppler/poppler-PATCHES/ChangeLog
+++ b/source/libs/poppler/poppler-PATCHES/ChangeLog
@@ -1,3 +1,9 @@
+2016-06-18  Akira Kakuto  <kakuto@fuk.kindai.ac.jp>
+
+	Imported poppler-0.45.0 source tree from:
+	  http://poppler.freedesktop.org/
+	* patch-02-LLONG_MAX, patch-03-Object-functions: Adapted.
+
 2016-05-22  Akira Kakuto  <kakuto@fuk.kindai.ac.jp>
 
 	Imported poppler-0.44.0 source tree from:
diff --git a/source/libs/poppler/poppler-PATCHES/TL-Changes b/source/libs/poppler/poppler-PATCHES/TL-Changes
index d060f7dbf676d0a1e0a92a29cc4849c196a4bc45..67ec763600cdf5fe5ab4045bd534b0813d44ec32 100644
--- a/source/libs/poppler/poppler-PATCHES/TL-Changes
+++ b/source/libs/poppler/poppler-PATCHES/TL-Changes
@@ -1,4 +1,4 @@
-Changes applied to the poppler-0.44.0 tree as obtained from:
+Changes applied to the poppler-0.45.0 tree as obtained from:
 	http://poppler.freedesktop.org/
 
 Removed:
diff --git a/source/libs/poppler/poppler-PATCHES/patch-02-LLONG_MAX b/source/libs/poppler/poppler-PATCHES/patch-02-LLONG_MAX
index 6431133c57ba6481100a4ef2327a17a36a12f909..565e0336f7c31f8cb39c31efc0277c4c4496f7b1 100644
--- a/source/libs/poppler/poppler-PATCHES/patch-02-LLONG_MAX
+++ b/source/libs/poppler/poppler-PATCHES/patch-02-LLONG_MAX
@@ -1,6 +1,6 @@
-diff -ur poppler-0.44.0.orig/goo/GooString.h poppler-0.44.0/goo/GooString.h
---- poppler-0.44.0.orig/goo/GooString.h	Wed May 11 07:47:44 2016
-+++ poppler-0.44.0/goo/GooString.h	Sun May 22 07:38:25 2016
+diff -ur poppler-0.45.0.orig/goo/GooString.h poppler-0.45.0/goo/GooString.h
+--- poppler-0.45.0.orig/goo/GooString.h	Wed May 11 07:47:44 2016
++++ poppler-0.45.0/goo/GooString.h	Sat Jun 18 06:46:31 2016
 @@ -36,6 +36,21 @@
  #endif
  
diff --git a/source/libs/poppler/poppler-PATCHES/patch-03-Object-functions b/source/libs/poppler/poppler-PATCHES/patch-03-Object-functions
index df2d0032546ce0c8c2c11ba38de3a3a7622c0cea..9d530d649cac1665ddff08159bfb939f2153b218 100644
--- a/source/libs/poppler/poppler-PATCHES/patch-03-Object-functions
+++ b/source/libs/poppler/poppler-PATCHES/patch-03-Object-functions
@@ -1,6 +1,6 @@
-diff -ur poppler-0.44.0.orig/poppler/Object.h poppler-0.44.0/poppler/Object.h
---- poppler-0.44.0.orig/poppler/Object.h	Mon May 02 07:08:03 2016
-+++ poppler-0.44.0/poppler/Object.h	Sun May 22 07:42:07 2016
+diff -ur poppler-0.45.0.orig/poppler/Object.h poppler-0.45.0/poppler/Object.h
+--- poppler-0.45.0.orig/poppler/Object.h	Wed Jun 01 01:40:39 2016
++++ poppler-0.45.0/poppler/Object.h	Sat Jun 18 06:49:28 2016
 @@ -147,7 +147,7 @@
    Object *initStream(Stream *streamA);
    Object *initRef(int numA, int genA)
diff --git a/source/libs/poppler/poppler-src/CMakeLists.txt b/source/libs/poppler/poppler-src/CMakeLists.txt
index dd81d27de5c962eb258b24d1c0c00d32a5baeeb1..34a5bdbc5e09f311f62a540987e6e0ad915fbed2 100644
--- a/source/libs/poppler/poppler-src/CMakeLists.txt
+++ b/source/libs/poppler/poppler-src/CMakeLists.txt
@@ -22,7 +22,7 @@ if (ECM_FOUND)
 endif()
 
 set(POPPLER_MAJOR_VERSION "0")
-set(POPPLER_MINOR_VERSION "44")
+set(POPPLER_MINOR_VERSION "45")
 set(POPPLER_MICRO_VERSION "0")
 set(POPPLER_VERSION "${POPPLER_MAJOR_VERSION}.${POPPLER_MINOR_VERSION}.${POPPLER_MICRO_VERSION}")
 
@@ -325,6 +325,7 @@ set(poppler_SRCS
   goo/ImgWriter.cc
   goo/gstrtod.cc
   goo/grandom.cc
+  goo/glibc.cc
   fofi/FoFiBase.cc
   fofi/FoFiEncodings.cc
   fofi/FoFiTrueType.cc
@@ -501,7 +502,7 @@ add_library(poppler STATIC ${poppler_SRCS})
 else(MSVC)
 add_library(poppler SHARED ${poppler_SRCS})
 endif(MSVC)
-set_target_properties(poppler PROPERTIES VERSION 61.0.0 SOVERSION 61)
+set_target_properties(poppler PROPERTIES VERSION 62.0.0 SOVERSION 62)
 target_link_libraries(poppler LINK_PRIVATE ${poppler_LIBS})
 install(TARGETS poppler RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX})
 
diff --git a/source/libs/poppler/poppler-src/ChangeLog b/source/libs/poppler/poppler-src/ChangeLog
index 8b64962a4f5aca8908dfd105560967ee178decda..e87511f5223cc010c8d9954f377013db960dc915 100644
--- a/source/libs/poppler/poppler-src/ChangeLog
+++ b/source/libs/poppler/poppler-src/ChangeLog
@@ -1,3 +1,288 @@
+commit dfbb98327cbbc173a63f5db36b6606a93e5166aa
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Fri Jun 17 00:04:25 2016 +0200
+
+    Poppler 0.45
+
+ CMakeLists.txt      |  4 ++--
+ NEWS                | 19 +++++++++++++++++++
+ configure.ac        |  2 +-
+ cpp/Doxyfile        |  2 +-
+ poppler/Makefile.am |  2 +-
+ qt4/src/Doxyfile    |  2 +-
+ qt5/src/Doxyfile    |  2 +-
+ 7 files changed, 26 insertions(+), 7 deletions(-)
+
+commit 3829958339b332d7ddf005d5ab98dd0ad3c8b3c6
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Thu Jun 16 23:58:07 2016 +0200
+
+    Add (C)
+
+ poppler/DateInfo.cc | 1 +
+ poppler/DateInfo.h  | 1 +
+ poppler/Form.cc     | 2 +-
+ utils/pdfinfo.cc    | 2 +-
+ 4 files changed, 4 insertions(+), 2 deletions(-)
+
+commit 4c7e057b0315ed37bd47e304ca191191244b2963
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Fri Jun 17 00:11:50 2016 +0200
+
+    dist glibc.h
+
+    we don't install it, but we need it for building
+
+ goo/Makefile.am | 2 ++
+ 1 file changed, 2 insertions(+)
+
+commit 5ee67050c400daa7bc0b0a4f5dddf21be18be124
+Author: Adrian Johnson <ajohnson@redneon.com>
+Date:   Tue Jun 14 07:32:35 2016 +0930
+
+    Fix windows compile
+
+ utils/pdfinfo.cc | 1 +
+ 1 file changed, 1 insertion(+)
+
+commit df0779031d6ae0180024f92602bc2a680cf73dd5
+Author: Jakub Kucharski <jakubkucharski97@gmail.com>
+Date:   Thu May 19 16:11:04 2016 +0200
+
+    cpp: switched from detail::convert_date() to core's dateStringToTime()
+
+ cpp/poppler-document.cpp      |  4 +++-
+ cpp/poppler-embedded-file.cpp |  6 ++++--
+ cpp/poppler-global.cpp        |  6 +++++-
+ cpp/poppler-private.cpp       | 25 +------------------------
+ cpp/poppler-private.h         |  3 +--
+ 5 files changed, 14 insertions(+), 30 deletions(-)
+
+commit ff24d677c6078c3dfb54c35541369d908314bcdb
+Author: Adrian Johnson <ajohnson@redneon.com>
+Date:   Wed Feb 24 20:57:37 2016 +1030
+
+    pdfinfo: add -isodates for printing dates in ISO-8601 format
+
+ utils/pdfinfo.1  |  3 +++
+ utils/pdfinfo.cc | 36 +++++++++++++++++++++++++++++++++++-
+ 2 files changed, 38 insertions(+), 1 deletion(-)
+
+commit dd08f24f5e52c56546dfda70be483dc29e03c2e6
+Author: Adrian Johnson <ajohnson@redneon.com>
+Date:   Wed Feb 24 21:10:08 2016 +1030
+
+    pdfinfo: convert dates to local time zone
+
+ utils/pdfinfo.cc | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+commit e4690ee1be027dd7028e86ea6732a3f4f2680ef7
+Author: Adrian Johnson <ajohnson@redneon.com>
+Date:   Tue Feb 23 21:01:49 2016 +1030
+
+    glib: return date in UTC instead of local time
+
+    Bug 94173
+
+ ConfigureChecks.cmake |  1 +
+ config.h.cmake        |  3 +++
+ configure.ac          |  1 +
+ glib/poppler-date.cc  | 33 +++++++-------------------------
+ goo/glibc.cc          | 24 ++++++++++++++++++++++++
+ goo/glibc.h           |  4 ++++
+ poppler/DateInfo.cc   | 52
+ +++++++++++++++++++++++++++++----------------------
+ poppler/DateInfo.h    |  6 +++++-
+ poppler/Form.cc       |  2 +-
+ 9 files changed, 76 insertions(+), 50 deletions(-)
+
+commit 7936af2eeb8f84993acabd1b306da50d49256b31
+Author: Adrian Johnson <ajohnson@redneon.com>
+Date:   Tue Feb 23 20:52:30 2016 +1030
+
+    Emulate some non portable glibc functions when not available
+
+ CMakeLists.txt             |  1 +
+ cpp/tests/poppler-dump.cpp |  5 +----
+ glib/demo/utils.c          |  6 ------
+ goo/Makefile.am            |  3 ++-
+ goo/glibc.cc               | 34 ++++++++++++++++++++++++++++++++++
+ goo/glibc.h                | 33 +++++++++++++++++++++++++++++++++
+ poppler/DateInfo.cc        |  7 ++-----
+ 7 files changed, 73 insertions(+), 16 deletions(-)
+
+commit 4d799cdf9b9039b003de7d3baf05d858bc507a5a
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Thu Jun 2 00:22:05 2016 +0200
+
+    pdfinfo: Fix another leak
+
+    Again not crucial in pdfinfo itself but nice to be clean so that if it
+    the leak check fails is because the core is doing something bad
+
+ utils/JSInfo.cc | 13 ++++++++-----
+ utils/JSInfo.h  |  3 ++-
+ 2 files changed, 10 insertions(+), 6 deletions(-)
+
+commit 4daee8a8ce40aeb658964a5902ae104549f7af75
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Wed Jun 1 18:37:57 2016 +0200
+
+    Fix memory leak when failing to parse thumbs or actions
+
+ poppler/Page.cc | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+commit bc6eb28776feaa302ad93e315798cad02c1e2a54
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Wed Jun 1 18:36:17 2016 +0200
+
+    pdfinto: Fix memory leak
+
+    It's not very critial that pdfinfo does not leak, but it's nice
+    to have no leaks so one can run ASAN over a file and see if something
+    is wrong or not
+
+ utils/pdfinfo.cc | 1 +
+ 1 file changed, 1 insertion(+)
+
+commit 66617b256acfcd98f727bf11b7d7e92bcbd16de0
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Wed Jun 1 18:35:50 2016 +0200
+
+    Point ucs4 to null when len is 0
+
+    Makes it easier for the caller than can always just free the passed
+    pointer
+
+ poppler/UTF.cc | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+commit 0d70a57c7ad8a53e2462560a47b6ea5eba73d6c5
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Wed Jun 1 18:34:32 2016 +0200
+
+    Add docu to the get*Action methods
+
+    Since unfortunately their behaviour is different in what you have
+    to do with the pointer given
+
+ poppler/Annot.h | 12 ++++++------
+ poppler/Form.h  |  6 +++---
+ 2 files changed, 9 insertions(+), 9 deletions(-)
+
+commit 3db727f9546779a8896fc30a6669751d726ab86c
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Wed Jun 1 18:32:45 2016 +0200
+
+    Fix memory leak in RichMedia parsing
+
+ poppler/Annot.cc | 1 +
+ 1 file changed, 1 insertion(+)
+
+commit 8ace48fb07b81cab6ae68dc23d173e7441ad6d2e
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Sun May 29 11:45:55 2016 +0200
+
+    SplashOutputDev: Fix iccTransform + splashModeXBGR8
+
+ poppler/SplashOutputDev.cc | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+commit 46039c2ef5b666d5ee85e7f6fc6a74a5a9e69526
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Fri May 27 11:06:01 2016 +0200
+
+    Add braces to make it more clear to which if the else applies
+
+ poppler/UnicodeTypeTable.cc | 21 ++++++++++++---------
+ 1 file changed, 12 insertions(+), 9 deletions(-)
+
+commit 2d72a8bfc87c9bdcea6b617ebd4b3a3684e174e8
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Thu May 26 17:59:21 2016 +0200
+
+    Initialize nConfigurations and nAssets
+
+ poppler/Annot.cc | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+commit 4e49b3af7d6f731b9da20a9d6e5aa54578f08d3f
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Thu May 26 17:34:56 2016 +0200
+
+    Fix memory leak on error on JBIG2Stream::readHalftoneRegionSeg
+
+ poppler/JBIG2Stream.cc | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+commit 5f51939eea5b98dcef115d18baec3179701d0292
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Tue May 24 23:34:48 2016 +0200
+
+    Fix stack overflow
+
+    Bug #96027
+
+ poppler/Stream.cc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+commit c820826377d79438ecaf90e9b2106a8451585add
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Tue May 24 00:00:57 2016 +0200
+
+    Fix (C) year
+
+ utils/HtmlOutputDev.cc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+commit 9ce8dd7fbd132b5f423dc3bf10fa87b973390d0b
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Mon May 23 23:59:40 2016 +0200
+
+    Fix stack overflow on broken file
+
+    Bug #95567
+
+ poppler/Stream.cc | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+commit 37fb37e368c659832fc1a1dfd499c42340b62f38
+Author: Vincent Le Garrec <legarrec.vincent@gmail.com>
+Date:   Mon May 23 23:18:40 2016 +0200
+
+    pdftohtml: Fix crash on broken file
+
+    Bug #95563
+
+ utils/HtmlOutputDev.cc | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+commit 1d0251c8ab48e2e1a4873d84b4bc573b3ae2a98d
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Sat May 21 20:02:26 2016 +0200
+
+    Fix memory leak in Splash::gouraudTriangleShadedFill
+
+ splash/Splash.cc | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+commit eb20f8cc2c0dea281ae44336a8fac8cc86a99895
+Author: Albert Astals Cid <aacid@kde.org>
+Date:   Sat May 21 19:19:43 2016 +0200
+
+    0.44
+
+ CMakeLists.txt      |  4 ++--
+ NEWS                | 16 ++++++++++++++++
+ configure.ac        |  2 +-
+ cpp/Doxyfile        |  2 +-
+ poppler/Makefile.am |  2 +-
+ qt4/src/Doxyfile    |  2 +-
+ qt5/src/Doxyfile    |  2 +-
+ 7 files changed, 23 insertions(+), 7 deletions(-)
+
 commit 58f56a7af99b477f39e57aed74443b6851afe15f
 Author: Thomas Freitag <Thomas.Freitag@alfa.de>
 Date:   Sat May 21 18:25:22 2016 +0200
diff --git a/source/libs/poppler/poppler-src/ConfigureChecks.cmake b/source/libs/poppler/poppler-src/ConfigureChecks.cmake
index d3f573257202765775f762da2c53d72be290206c..345f29c56fba21e45ba92e5a28a46a1ec7a74e87 100644
--- a/source/libs/poppler/poppler-src/ConfigureChecks.cmake
+++ b/source/libs/poppler/poppler-src/ConfigureChecks.cmake
@@ -30,6 +30,7 @@ check_function_exists(ftell64 HAVE_FTELL64)
 check_function_exists(pread64 HAVE_PREAD64)
 check_function_exists(lseek64 HAVE_LSEEK64)
 check_function_exists(gmtime_r HAVE_GMTIME_R)
+check_function_exists(timegm HAVE_TIMEGM)
 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
 check_function_exists(localtime_r HAVE_LOCALTIME_R)
 check_function_exists(popen HAVE_POPEN)
diff --git a/source/libs/poppler/poppler-src/NEWS b/source/libs/poppler/poppler-src/NEWS
index 558efd8133ee0cd07c0bbe37ffa69ae4ea847636..d5762ab64e84d4cdbdd1f0e5044fb3c975e48c64 100644
--- a/source/libs/poppler/poppler-src/NEWS
+++ b/source/libs/poppler/poppler-src/NEWS
@@ -1,3 +1,22 @@
+Release 0.45.0
+        core:
+         * SplashOutputDev: Fix iccTransform + splashModeXBGR8
+         * Fix memory leaks
+         * Fix crash in broken files. Bug #95567. Bug #96027
+         * Emulate some non portable glibc functions when not available
+
+        utils:
+         * pdftohtml: Fix crash in broken files. Bug #95563
+         * pdfinfo: convert dates to local time zone
+         * pdfinfo: add -isodates for printing dates in ISO-8601 format
+         * pdfinfo: Fix memory leaks
+
+        glib:
+         * return date in UTC instead of local time. Bug #94173
+
+        cpp:
+         * switched from detail::convert_date() to core's dateStringToTime()
+
 Release 0.44.0
         core:
          * Fix Compile in 32bit linux. Bug #95492
diff --git a/source/libs/poppler/poppler-src/config.h.cmake b/source/libs/poppler/poppler-src/config.h.cmake
index 85c6d3289efdde82ab96be340d3704506c65c132..7988b74e31a796c380c4dd5905a3fb05c9297369 100644
--- a/source/libs/poppler/poppler-src/config.h.cmake
+++ b/source/libs/poppler/poppler-src/config.h.cmake
@@ -64,6 +64,9 @@
 /* Defines if gmtime_r is available on your system */
 #cmakedefine HAVE_GMTIME_R 1
 
+/* Defines if timegm is available on your system */
+#cmakedefine HAVE_TIMEGM 1
+
 /* Define if you have the iconv() function and it works. */
 #cmakedefine HAVE_ICONV 1
 
diff --git a/source/libs/poppler/poppler-src/config.h.in b/source/libs/poppler/poppler-src/config.h.in
index 1933cc8bcfcd2a39efc0c2151769fdf94c2b906f..302f7b9ccea0a02821bdbf9bd47e7bf79531b2b8 100644
--- a/source/libs/poppler/poppler-src/config.h.in
+++ b/source/libs/poppler/poppler-src/config.h.in
@@ -150,6 +150,9 @@
 /* Define to 1 if you have the <tiffio.h> header file. */
 #undef HAVE_TIFFIO_H
 
+/* Defines if timegm is available on your system */
+#undef HAVE_TIMEGM
+
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
diff --git a/source/libs/poppler/poppler-src/configure.ac b/source/libs/poppler/poppler-src/configure.ac
index 8ff8ea50116063b30b71d68a389d2ab8a25e6c58..7a1455d261cafe6e4eb9c045977723390be25088 100644
--- a/source/libs/poppler/poppler-src/configure.ac
+++ b/source/libs/poppler/poppler-src/configure.ac
@@ -1,5 +1,5 @@
 m4_define([poppler_version_major],[0])
-m4_define([poppler_version_minor],[44])
+m4_define([poppler_version_minor],[45])
 m4_define([poppler_version_micro],[0])
 m4_define([poppler_version],[poppler_version_major.poppler_version_minor.poppler_version_micro])
 
@@ -178,6 +178,7 @@ AC_LANG_CPLUSPLUS
 AC_CHECK_DECL(gettimeofday, [AC_CHECK_FUNC(gettimeofday, AC_DEFINE(HAVE_GETTIMEOFDAY, 1, [Defines if gettimeofday is available on your system]))],[],[#include <sys/time.h>])
 AC_CHECK_FUNC(localtime_r, AC_DEFINE(HAVE_LOCALTIME_R, 1, [Defines if localtime_r is available on your system]))
 AC_CHECK_FUNC(gmtime_r, AC_DEFINE(HAVE_GMTIME_R, 1, [Defines if gmtime_r is available on your system]))
+AC_CHECK_FUNC(timegm, AC_DEFINE(HAVE_TIMEGM, 1, [Defines if timegm is available on your system]))
 AC_CHECK_FUNC(rand_r, AC_DEFINE(HAVE_RAND_R, 1, [Defines if rand_r is available on your system]))
 
 dnl ##### Check for extra libraries needed by X.  (LynxOS needs this.)
diff --git a/source/libs/poppler/poppler-src/goo/Makefile.am b/source/libs/poppler/poppler-src/goo/Makefile.am
index 370e85021be5577ea44cbc0b9f2542ad335f1b1b..004775a487cfd5f5c03ef3c107f457287ba19ef1 100644
--- a/source/libs/poppler/poppler-src/goo/Makefile.am
+++ b/source/libs/poppler/poppler-src/goo/Makefile.am
@@ -40,7 +40,8 @@ libgoo_la_SOURCES =				\
 	ImgWriter.cc				\
 	gtypes_p.h				\
 	gstrtod.cc				\
-	grandom.cc
+	grandom.cc                              \
+	glibc.cc
 
 if BUILD_LIBJPEG
 libjpeg_includes = $(LIBJPEG_CFLAGS)
@@ -64,3 +65,5 @@ libgoo_la_CPPFLAGS =				\
 	$(libtiff_includes)                     \
 	$(libjpeg2000_includes)                 \
 	$(libpng_includes)
+
+EXTRA_DIST = glibc.h
\ No newline at end of file
diff --git a/source/libs/poppler/poppler-src/poppler/Annot.cc b/source/libs/poppler/poppler-src/poppler/Annot.cc
index c20398bd936a1d1135fbe3d659c99a77f0789b1e..51a80e5d9c293164d58b3e06945822f75cc8d62f 100644
--- a/source/libs/poppler/poppler-src/poppler/Annot.cc
+++ b/source/libs/poppler/poppler-src/poppler/Annot.cc
@@ -15,7 +15,7 @@
 //
 // Copyright (C) 2006 Scott Turner <scotty1024@mac.com>
 // Copyright (C) 2007, 2008 Julien Rebetez <julienr@svn.gnome.org>
-// Copyright (C) 2007-2013, 2015 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2007-2013, 2015, 2016 Albert Astals Cid <aacid@kde.org>
 // Copyright (C) 2007-2013 Carlos Garcia Campos <carlosgc@gnome.org>
 // Copyright (C) 2007, 2008 Iñigo Martínez <inigomartinez@gmail.com>
 // Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net>
@@ -6849,6 +6849,7 @@ AnnotRichMedia::Content::Content(Dict *dict) {
       obj2.free();
     }
   } else {
+    nConfigurations = 0;
     configurations = NULL;
   }
   obj1.free();
@@ -6879,6 +6880,7 @@ AnnotRichMedia::Content::Content(Dict *dict) {
     obj2.free();
 
   } else {
+    nAssets = 0;
     assets = NULL;
   }
   obj1.free();
@@ -7064,6 +7066,7 @@ AnnotRichMedia::Instance::Instance(Dict *dict)
   } else {
     params = NULL;
   }
+  obj1.free();
 }
 
 AnnotRichMedia::Instance::~Instance()
diff --git a/source/libs/poppler/poppler-src/poppler/Annot.h b/source/libs/poppler/poppler-src/poppler/Annot.h
index d90c8080ffed878524acb0af60fac20b17443a1d..dfafe4f90c84066ea137f873cede03ce3a0e4b72 100644
--- a/source/libs/poppler/poppler-src/poppler/Annot.h
+++ b/source/libs/poppler/poppler-src/poppler/Annot.h
@@ -21,7 +21,7 @@
 // Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com>
 // Copyright (C) 2008 Pino Toscano <pino@kde.org>
 // Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com>
-// Copyright (C) 2009-2011, 2013 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2009-2011, 2013, 2016 Albert Astals Cid <aacid@kde.org>
 // Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it>
 // Copyright (C) 2012, 2015 Tobias Koenig <tokoe@kdab.com>
 // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
@@ -847,8 +847,8 @@ class AnnotScreen: public Annot {
   GooString* getTitle() { return title; }
 
   AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs; }
-  LinkAction* getAction() { return action; }
-  LinkAction *getAdditionalAction(AdditionalActionsType type);
+  LinkAction* getAction() { return action; } // The caller should now delete the result
+  LinkAction *getAdditionalAction(AdditionalActionsType type); // The caller should delete the result
 
  private:
   void initialize(PDFDoc *docA, Dict *dict);
@@ -1322,9 +1322,9 @@ public:
 
   AnnotWidgetHighlightMode getMode() { return mode; }
   AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs; }
-  LinkAction *getAction() { return action; }
-  LinkAction *getAdditionalAction(AdditionalActionsType type);
-  LinkAction *getFormAdditionalAction(FormAdditionalActionsType type);
+  LinkAction *getAction() { return action; }  // The caller should not delete the result
+  LinkAction *getAdditionalAction(AdditionalActionsType type); // The caller should delete the result
+  LinkAction *getFormAdditionalAction(FormAdditionalActionsType type); // The caller should delete the result
   Dict *getParent() { return parent; }
 
 private:
diff --git a/source/libs/poppler/poppler-src/poppler/DateInfo.cc b/source/libs/poppler/poppler-src/poppler/DateInfo.cc
index 8cd4883d3045bbd9d053b0c98a4c787ba04e3e8e..fef3f00a658f2914bed19b5ea81b13f8d3f44b1b 100644
--- a/source/libs/poppler/poppler-src/poppler/DateInfo.cc
+++ b/source/libs/poppler/poppler-src/poppler/DateInfo.cc
@@ -6,6 +6,7 @@
 // Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
 // Copyright (C) 2015 André Guerreiro <aguerreiro1985@gmail.com>
 // Copyright (C) 2015 André Esser <bepandre@hotmail.com>
+// Copyright (C) 2016 Adrian Johnson <ajohnson@redneon.com>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -22,6 +23,7 @@
 
 #include <config.h>
 
+#include "glibc.h"
 #include "DateInfo.h"
 
 #include <stdio.h>
@@ -74,20 +76,16 @@ GBool parseDateString(const char *dateString, int *year, int *month, int *day, i
    return gFalse;
 }
 
-
+// Convert time to PDF date string
 GooString *timeToDateString(time_t *timet) {
   GooString *dateString;
   char s[5];
   struct tm *gt;
   size_t len;
   time_t timep = timet ? *timet : time(NULL);
-  
-#ifdef HAVE_GMTIME_R
   struct tm t;
+
   gt = gmtime_r (&timep, &t);
-#else
-  gt = gmtime (&timep);
-#endif
 
   dateString = new GooString ("D:");
 
@@ -118,27 +116,35 @@ GooString *timeToDateString(time_t *timet) {
   return dateString;
 }
 
-time_t pdfTimeToInteger(GooString *time_str)
-{
+// Convert PDF date string to time. Returns -1 if conversion fails.
+time_t dateStringToTime(GooString *dateString) {
   int year, mon, day, hour, min, sec, tz_hour, tz_minute;
   char tz;
-  struct tm time_struct;
-
-  if (!parseDateString (time_str->getCString(), &year,
-        &mon, &day, &hour, &min, &sec, &tz, &tz_hour, &tz_minute))
-    return 0;
-
-  time_struct.tm_year = year - 1900;
-  time_struct.tm_mon = mon - 1;
-  time_struct.tm_mday = day;
-  time_struct.tm_hour = hour;
-  time_struct.tm_min = min;
-  time_struct.tm_sec = sec;
-  time_struct.tm_wday = -1;
-  time_struct.tm_yday = -1;
-  time_struct.tm_isdst = -1;
-
-  time_t unix_time = mktime(&time_struct);
-
-  return unix_time;
+  struct tm tm;
+  time_t time;
+
+  if (!parseDateString (dateString->getCString(), &year, &mon, &day, &hour, &min, &sec, &tz, &tz_hour, &tz_minute))
+    return -1;
+
+  tm.tm_year = year - 1900;
+  tm.tm_mon = mon - 1;
+  tm.tm_mday = day;
+  tm.tm_hour = hour;
+  tm.tm_min = min;
+  tm.tm_sec = sec;
+  tm.tm_wday = -1;
+  tm.tm_yday = -1;
+  tm.tm_isdst = -1; /* 0 = DST off, 1 = DST on, -1 = don't know */
+
+  /* compute tm_wday and tm_yday and check date */
+  time = timegm (&tm);
+  if (time == (time_t)-1)
+    return time;
+
+  time_t offset = (tz_hour*60 + tz_minute)*60;
+  if (tz == '-')
+    offset *= -1;
+  time -= offset;
+
+  return time;
 }
diff --git a/source/libs/poppler/poppler-src/poppler/DateInfo.h b/source/libs/poppler/poppler-src/poppler/DateInfo.h
index 840ee5ac17fc1dc7ce091074960adaf5aa75598c..468dd93bae6039b114235eac9b314ece72bd0f6e 100644
--- a/source/libs/poppler/poppler-src/poppler/DateInfo.h
+++ b/source/libs/poppler/poppler-src/poppler/DateInfo.h
@@ -6,6 +6,7 @@
 // Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
 // Copyright (C) 2015 André Guerreiro <aguerreiro1985@gmail.com>
 // Copyright (C) 2015 André Esser <bepandre@hotmail.com>
+// Copyright (C) 2016 Adrian Johnson <ajohnson@redneon.com>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -33,6 +34,10 @@ GBool parseDateString(const char *string, int *year, int *month, int *day, int *
  * If timet is NULL, current time is used.
  */
 GooString *timeToDateString(time_t *timet);
-time_t pdfTimeToInteger(GooString *time_str);
+
+/* Convert PDF date string to time.
+ * Returns -1 if conversion fails.
+ */
+time_t dateStringToTime(GooString *dateString);
 
 #endif
diff --git a/source/libs/poppler/poppler-src/poppler/Form.cc b/source/libs/poppler/poppler-src/poppler/Form.cc
index 4dd56b7800d88ccd44294b53b1d47d61873e6f3e..d5f4dd11d519f34778fc135f81ce894a316aa1b3 100644
--- a/source/libs/poppler/poppler-src/poppler/Form.cc
+++ b/source/libs/poppler/poppler-src/poppler/Form.cc
@@ -7,7 +7,7 @@
 // Copyright 2006-2008 Julien Rebetez <julienr@svn.gnome.org>
 // Copyright 2007-2012, 2015, 2016 Albert Astals Cid <aacid@kde.org>
 // Copyright 2007-2008, 2011 Carlos Garcia Campos <carlosgc@gnome.org>
-// Copyright 2007, 2013 Adrian Johnson <ajohnson@redneon.com>
+// Copyright 2007, 2013, 2016 Adrian Johnson <ajohnson@redneon.com>
 // Copyright 2007 Iñigo Martínez <inigomartinez@gmail.com>
 // Copyright 2008, 2011 Pino Toscano <pino@kde.org>
 // Copyright 2008 Michael Vrable <mvrable@cs.ucsd.edu>
@@ -1421,7 +1421,7 @@ void FormFieldSignature::parseInfo()
   sig_dict.dictLookup("M", &time_of_signing);
   if (time_of_signing.isString()) {
     GooString *time_str = time_of_signing.getString();
-    signature_info->setSigningTime(pdfTimeToInteger(time_str)); // Put this information directly in SignatureInfo object
+    signature_info->setSigningTime(dateStringToTime(time_str)); // Put this information directly in SignatureInfo object
     time_of_signing.free();
   }
 
diff --git a/source/libs/poppler/poppler-src/poppler/Form.h b/source/libs/poppler/poppler-src/poppler/Form.h
index b566fe038542fe6e0ca8fb2c23205c56fe2c07b0..d467b473bcd9d0510d3871c59d2777b490932ed2 100644
--- a/source/libs/poppler/poppler-src/poppler/Form.h
+++ b/source/libs/poppler/poppler-src/poppler/Form.h
@@ -6,7 +6,7 @@
 //
 // Copyright 2006 Julien Rebetez <julienr@svn.gnome.org>
 // Copyright 2007, 2008, 2011 Carlos Garcia Campos <carlosgc@gnome.org>
-// Copyright 2007-2010, 2012, 2015 Albert Astals Cid <aacid@kde.org>
+// Copyright 2007-2010, 2012, 2015, 2016 Albert Astals Cid <aacid@kde.org>
 // Copyright 2010 Mark Riedesel <mark@klowner.com>
 // Copyright 2011 Pino Toscano <pino@kde.org>
 // Copyright 2012 Fabio D'Urso <fabiodurso@hotmail.it>
@@ -106,8 +106,8 @@ public:
 
   bool isReadOnly() const;
 
-  LinkAction *getActivationAction();
-  LinkAction *getAdditionalAction(Annot::FormAdditionalActionsType type);
+  LinkAction *getActivationAction(); // The caller should not delete the result
+  LinkAction *getAdditionalAction(Annot::FormAdditionalActionsType type); // The caller should delete the result
 
   // return the unique ID corresponding to pageNum/fieldNum
   static int encodeID (unsigned pageNum, unsigned fieldNum);
diff --git a/source/libs/poppler/poppler-src/poppler/JBIG2Stream.cc b/source/libs/poppler/poppler-src/poppler/JBIG2Stream.cc
index a20c220811550b2266e4ec56f2da8a412164abd4..9f12d5dad2ff5258c2b62ddcb80f109a090bb9dd 100644
--- a/source/libs/poppler/poppler-src/poppler/JBIG2Stream.cc
+++ b/source/libs/poppler/poppler-src/poppler/JBIG2Stream.cc
@@ -15,7 +15,7 @@
 //
 // Copyright (C) 2006 Raj Kumar <rkumar@archive.org>
 // Copyright (C) 2006 Paul Walmsley <paul@booyaka.com>
-// Copyright (C) 2006-2010, 2012, 2014, 2015 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012, 2014-2016 Albert Astals Cid <aacid@kde.org>
 // Copyright (C) 2009 David Benjamin <davidben@mit.edu>
 // Copyright (C) 2011 Edward Jiang <ejiang@google.com>
 // Copyright (C) 2012 William Bader <williambader@hotmail.com>
@@ -2770,6 +2770,9 @@ void JBIG2Stream::readHalftoneRegionSeg(Guint segNum, GBool imm,
       if (!(enableSkip && skipBitmap->getPixel(n, m))) {
 	patternBitmap = patternDict->getBitmap(grayImg[i]);
 	if (unlikely(patternBitmap == NULL)) {
+	  delete skipBitmap;
+	  delete bitmap;
+	  gfree(grayImg);
 	  error(errSyntaxError, curStr->getPos(), "Bad pattern bitmap");
 	  return;
 	}
diff --git a/source/libs/poppler/poppler-src/poppler/Makefile.am b/source/libs/poppler/poppler-src/poppler/Makefile.am
index 3eef543a3567bbab1ca27479e8977535bf567e77..3d32e792f94a7c17eca237989f789e42fea1e7a0 100644
--- a/source/libs/poppler/poppler-src/poppler/Makefile.am
+++ b/source/libs/poppler/poppler-src/poppler/Makefile.am
@@ -327,7 +327,7 @@ libpoppler_la_LIBADD =				\
 	$(win32_libs)
 
 libpoppler_la_LDFLAGS =				\
-	-version-info 61:0:0			\
+	-version-info 62:0:0			\
 	@create_shared_lib@			\
 	@auto_import_flags@
 
diff --git a/source/libs/poppler/poppler-src/poppler/Page.cc b/source/libs/poppler/poppler-src/poppler/Page.cc
index a4af3405b926d46a0d58b9664c729a78d5db46db..dca52e4faae783d3c1fa4b3defd91d8a9a5bf348 100644
--- a/source/libs/poppler/poppler-src/poppler/Page.cc
+++ b/source/libs/poppler/poppler-src/poppler/Page.cc
@@ -15,7 +15,7 @@
 //
 // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
 // Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2005-2013 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2005-2013, 2016 Albert Astals Cid <aacid@kde.org>
 // Copyright (C) 2006-2008 Pino Toscano <pino@kde.org>
 // Copyright (C) 2006 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
 // Copyright (C) 2006 Scott Turner <scotty1024@mac.com>
@@ -325,6 +325,7 @@ Page::Page(PDFDoc *docA, int numA, Dict *pageDict, Ref pageRefA, PageAttrs *attr
   if (!(thumb.isStream() || thumb.isNull() || thumb.isRef())) {
       error(errSyntaxError, -1, "Page thumb object (page {0:d}) is wrong type ({1:s})",
             num, thumb.getTypeName());
+      thumb.free();
       thumb.initNull(); 
   }
 
@@ -333,6 +334,7 @@ Page::Page(PDFDoc *docA, int numA, Dict *pageDict, Ref pageRefA, PageAttrs *attr
   if (!(actions.isDict() || actions.isNull())) {
       error(errSyntaxError, -1, "Page additional action object (page {0:d}) is wrong type ({1:s})",
             num, actions.getTypeName());
+      actions.free();
       actions.initNull();
   }
   
diff --git a/source/libs/poppler/poppler-src/poppler/SplashOutputDev.cc b/source/libs/poppler/poppler-src/poppler/SplashOutputDev.cc
index eeb6cc38b0e993612b3a5c0768d3c7da6e98d522..688540beaf0bc6832ddcc0923081e59f235e6d2f 100644
--- a/source/libs/poppler/poppler-src/poppler/SplashOutputDev.cc
+++ b/source/libs/poppler/poppler-src/poppler/SplashOutputDev.cc
@@ -3278,17 +3278,17 @@ void SplashOutputDev::iccTransform(void *data, SplashBitmap *bitmap) {
       Guchar *q;
       Guchar *b = p;
       int x;
-      for (x = 0, q = rgbxLine; x < bitmap->getWidth(); ++x, ++b) {
-        *q++ = *b++;
-        *q++ = *b++;
-        *q++ = *b++;
+      for (x = 0, q = rgbxLine; x < bitmap->getWidth(); ++x, b+=4) {
+        *q++ = b[2];
+        *q++ = b[1];
+        *q++ = b[0];
       }
       imgData->colorMap->getRGBLine(rgbxLine, colorLine, bitmap->getWidth());
       b = p;
-      for (x = 0, q = colorLine; x < bitmap->getWidth(); ++x, ++b) {
-        *b++ = *q++;
-        *b++ = *q++;
-        *b++ = *q++;
+      for (x = 0, q = colorLine; x < bitmap->getWidth(); ++x, b+=4) {
+        b[2] = *q++;
+        b[1] = *q++;
+        b[0] = *q++;
       }
       break;
     }
diff --git a/source/libs/poppler/poppler-src/poppler/Stream.cc b/source/libs/poppler/poppler-src/poppler/Stream.cc
index 1e6318e74fe99f073960922fb0ff41c03fe27696..4a9babe4662e2102f5aa8683126360b08ef16b3f 100644
--- a/source/libs/poppler/poppler-src/poppler/Stream.cc
+++ b/source/libs/poppler/poppler-src/poppler/Stream.cc
@@ -14,7 +14,7 @@
 // under GPL version 2 or later
 //
 // Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2006-2010, 2012-2014 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012-2014, 2016 Albert Astals Cid <aacid@kde.org>
 // Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
 // Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
 // Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -178,12 +178,12 @@ Stream *Stream::addFilters(Object *dict, int recursion) {
   dict->dictLookup("Filter", &obj, recursion);
   if (obj.isNull()) {
     obj.free();
-    dict->dictLookup("F", &obj);
+    dict->dictLookup("F", &obj, recursion);
   }
   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, dict);
diff --git a/source/libs/poppler/poppler-src/poppler/UTF.cc b/source/libs/poppler/poppler-src/poppler/UTF.cc
index 46007b730069198b99a0eee75b2402f5c74af65f..3b3ae35c39fa27493b42e0ce0cdb656f1a8db127 100644
--- a/source/libs/poppler/poppler-src/poppler/UTF.cc
+++ b/source/libs/poppler/poppler-src/poppler/UTF.cc
@@ -16,6 +16,7 @@
 // Copyright (C) 2008 Koji Otani <sho@bbr.jp>
 // Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>
 // Copyright (C) 2012 Hib Eris <hib@hiberis.nl>
+// Copyright (C) 2016 Albert Astals Cid <aacid@kde.org>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -89,8 +90,10 @@ int TextStringToUCS4(GooString *textStr, Unicode **ucs4)
 
   len = textStr->getLength();
   s = textStr->getCString();
-  if (len == 0)
+  if (len == 0) {
+    *ucs4 = 0;
     return 0;
+  }
 
   if (textStr->hasUnicodeMarker()) {
     Unicode *utf16;
diff --git a/source/libs/poppler/poppler-src/poppler/UnicodeTypeTable.cc b/source/libs/poppler/poppler-src/poppler/UnicodeTypeTable.cc
index c9f8e2a3b79b76684a020bd0ef2c6f42d830a22c..cd423c9f585c5d1cf57fb628314846465d005f80 100644
--- a/source/libs/poppler/poppler-src/poppler/UnicodeTypeTable.cc
+++ b/source/libs/poppler/poppler-src/poppler/UnicodeTypeTable.cc
@@ -15,7 +15,7 @@
 //
 // Copyright (C) 2006, 2007 Ed Catmur <ed@catmur.co.uk>
 // Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2008 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2008, 2016 Albert Astals Cid <aacid@kde.org>
 // Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>
 // Copyright (C) 2016 Khaled Hosny <khaledhosny@eglug.org>
 //
@@ -1028,16 +1028,19 @@ static int decomp_compat(Unicode u, Unicode *buf, GBool reverseRTL = false) {
       int midpoint = (start + end) / 2;
       if (u == decomp_table[midpoint].character) {
 	int offset = decomp_table[midpoint].offset;
-	if (offset == -1)
+	if (offset == -1) {
 	  break;
-	else {
+	} else {
 	  int length = decomp_table[midpoint].length, i;
-	  if (buf)
-	    for (i = 0; i < length; ++i)
-		if (unicodeTypeR(u) && reverseRTL)
-		  buf[i] = decomp_expansion[offset + length - i - 1];
-		else
-		  buf[i] = decomp_expansion[offset + i];
+	  if (buf) {
+	    for (i = 0; i < length; ++i) {
+	      if (unicodeTypeR(u) && reverseRTL) {
+		buf[i] = decomp_expansion[offset + length - i - 1];
+	      } else {
+		buf[i] = decomp_expansion[offset + i];
+	      }
+	    }
+	  }
 	  return length;
 	}
       } else if (midpoint == start)
diff --git a/source/libs/poppler/poppler-src/splash/Splash.cc b/source/libs/poppler/poppler-src/splash/Splash.cc
index 5acbe8eff9dffaab4a88c7efef3545ea825f15fa..4d33cf781b9985943260e190f57b1b640e10fb86 100644
--- a/source/libs/poppler/poppler-src/splash/Splash.cc
+++ b/source/libs/poppler/poppler-src/splash/Splash.cc
@@ -11,7 +11,7 @@
 // All changes made under the Poppler project to this file are licensed
 // under GPL version 2 or later
 //
-// Copyright (C) 2005-2015 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2005-2016 Albert Astals Cid <aacid@kde.org>
 // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com>
 // Copyright (C) 2010-2016 Thomas Freitag <Thomas.Freitag@alfa.de>
 // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com>
@@ -5768,6 +5768,9 @@ GBool Splash::gouraudTriangleShadedFill(SplashGouraudColor *shading)
       }
     }
   } else {
+    if (!bDirectBlit) {
+      delete blitTarget;
+    }
     return gFalse;
   }
 
diff --git a/source/libs/poppler/version.ac b/source/libs/poppler/version.ac
index 9ad21ab1cad826b9369ea698eb92589e44ef0a1b..a373074d143de9f5f07a63b1265071e59b94f5b1 100644
--- a/source/libs/poppler/version.ac
+++ b/source/libs/poppler/version.ac
@@ -8,4 +8,4 @@ dnl
 dnl --------------------------------------------------------
 dnl
 dnl  m4-include this file to define the current poppler version
-m4_define([poppler_version], [0.44.0])
+m4_define([poppler_version], [0.45.0])
diff --git a/source/tardate.ac b/source/tardate.ac
index 5f2290854688a5b9d1426f3a2e0816e925b4f530..4a87a1c5498ef64c2b18c4268d7b4d06b434214f 100644
--- a/source/tardate.ac
+++ b/source/tardate.ac
@@ -1,5 +1,6 @@
-dnl
-dnl   Copyright (C) 2010-2015 Peter Breitenlohner <tex-live@tug.org>
+dnl $Id: tardate.ac 41571 2016-06-29 23:09:13Z karl $
+dnl   Copyright 2016 Karl Berry <tex-live@tug.org>
+dnl   Copyright 2010-2015 Peter Breitenlohner <tex-live@tug.org>
 dnl
 dnl   This file is free software; the copyright holder
 dnl   gives unlimited permission to copy and/or distribute it,
@@ -8,4 +9,4 @@ dnl
 dnl --------------------------------------------------------
 dnl
 dnl  m4-include this file to define the current TeX Live tarball version
-m4_define([tex_live_tardate], [2015-06-12])
+m4_define([tex_live_tardate], [2016-05-23])
diff --git a/source/texk/README b/source/texk/README
index a3eae6caa4044d58f0a3b066a411eb31fffed3a9..6131c0f0f7c9cb247df0b1a4f38b4a93c5e34e0b 100644
--- a/source/texk/README
+++ b/source/texk/README
@@ -1,4 +1,4 @@
-$Id: README 40624 2016-04-19 23:51:42Z kakuto $
+$Id: README 41629 2016-07-04 22:11:23Z kakuto $
 Copyright 2006-2016 TeX Users Group.
 You may freely use, modify and/or distribute this file.
 
@@ -58,17 +58,17 @@ dvipos - ?
 
 dvipsk - maintained here, by us
 
-dvisvgm 1.15.1 - checked 20apr16
+dvisvgm 1.16 - checked 04jul16
   http://dvisvgm.bplaced.net/Downloads
 
-gregorio 4.1.1 - checked 11mar16
+gregorio 4.1.4 - checked 07jun16
   https://github.com/gregorio-project/gregorio/releases/
 
 gsftopk - from Paul Vojta's xdvi?
 
 kpathsea - maintained here, by us
 
-lcdf-typetools 2.105 - checked 27sep15
+lcdf-typetools 2.106 - checked 22jun16
   http://www.lcdf.org/type/
 
 makeindexk - maintained here, by us
@@ -98,7 +98,7 @@ ttf2pk2 - maintained here, by us
 
 ttfdump - ?
 
-upmendex 0.50 - 
+upmendex 0.51 - by Takuji Tanaka
   http://www.ctan.org/pkg/upmendex
   http://www.t-lab.opal.ne.jp/tex/uptex_en.html
 
diff --git a/source/texk/configure b/source/texk/configure
index d1a6f86d7874d19aaf9ff29f4862a5c265c84ec3..933f547f64b8cf896fab10187b9db5815ad09011 100755
--- a/source/texk/configure
+++ b/source/texk/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for TeX Live texk 2016.
+# Generated by GNU Autoconf 2.69 for TeX Live texk 2017/dev.
 #
 # Report bugs to <peb@mppmu.mpg.de>.
 #
@@ -579,8 +579,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='TeX Live texk'
 PACKAGE_TARNAME='tex-live-texk'
-PACKAGE_VERSION='2016'
-PACKAGE_STRING='TeX Live texk 2016'
+PACKAGE_VERSION='2017/dev'
+PACKAGE_STRING='TeX Live texk 2017/dev'
 PACKAGE_BUGREPORT='peb@mppmu.mpg.de'
 PACKAGE_URL=''
 
@@ -1319,7 +1319,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures TeX Live texk 2016 to adapt to many kinds of systems.
+\`configure' configures TeX Live texk 2017/dev to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1389,7 +1389,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of TeX Live texk 2016:";;
+     short | recursive ) echo "Configuration of TeX Live texk 2017/dev:";;
    esac
   cat <<\_ACEOF
 
@@ -1579,7 +1579,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-TeX Live texk configure 2016
+TeX Live texk configure 2017/dev
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1680,7 +1680,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by TeX Live texk $as_me 2016, which was
+It was created by TeX Live texk $as_me 2017/dev, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -4512,7 +4512,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='tex-live-texk'
- VERSION='2016'
+ VERSION='2017/dev'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -5442,7 +5442,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by TeX Live texk $as_me 2016, which was
+This file was extended by TeX Live texk $as_me 2017/dev, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5499,7 +5499,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-TeX Live texk config.status 2016
+TeX Live texk config.status 2017/dev
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/source/texk/kpathsea/ChangeLog b/source/texk/kpathsea/ChangeLog
index 59de2f05a723e307406ed73ede169c6a332f89ae..235a947f2e9079500ea2422d65289da6142fe7df 100644
--- a/source/texk/kpathsea/ChangeLog
+++ b/source/texk/kpathsea/ChangeLog
@@ -1,3 +1,28 @@
+2016-07-01  Akira Kakuto  <kakuto@fuk.kindai.ac.jp>
+
+	* knj.c, knj.h: Avoid compiler warnings.
+
+2016-06-30  Karl Berry  <karl@tug.org>
+
+	* version.ac (kpse_version): 6.2.2 => 6.2.3dev.
+
+2016-06-29  Akira Kakuto  <kakuto@fuk.kindai.ac.jp>
+
+	* kpsewhich.c: Remove unnecessary w32 changes,
+
+2016-06-28  Akira Kakuto  <kakuto@fuk.kindai.ac.jp>
+
+	* config.h, db.c, elt-dirs.c, expand.c, find-suffix.c, hash.c, knj.c,
+	knj.h, kpsewhich.c, make-suffix.c, path-elt.c, progname.c, readable.c,
+	tilde.c, types.h, variable.c, win32lib.c, win32lib.h, xbasename.c,
+	xdirname.c, xdirtest.c, xgetcwd.c: Eliminate global and static
+	variables (w32 only).
+
+2016-05-28  Akira Kakuto  <kakuto@fuk.kindai.ac.jp>
+
+	* tex-file.c: Fix a bug that TEXMFOUTPUT does not work (w32 only).
+	See http://tug.org/pipermail/tex-k/2016-May/002719.html.
+
 2016-05-20  Karl Berry  <karl@tug.org>
 
 	* Version 6.2.2 for TeX Live 2016.
diff --git a/source/texk/kpathsea/c-auto.in b/source/texk/kpathsea/c-auto.in
index f297e7960b63e4556fa93570ed79caef2e4d88a7..8125103bc235ebb7c3d5265b3ed6aba84df75278 100644
--- a/source/texk/kpathsea/c-auto.in
+++ b/source/texk/kpathsea/c-auto.in
@@ -23,7 +23,7 @@
 #define KPATHSEA_C_AUTO_H
 
 /* kpathsea: the version string. */
-#define KPSEVERSION "kpathsea version 6.2.2"
+#define KPSEVERSION "kpathsea version 6.2.3/dev"
 
 /* Define to 1 if the `closedir' function returns void instead of `int'. */
 #undef CLOSEDIR_VOID
diff --git a/source/texk/kpathsea/config.h b/source/texk/kpathsea/config.h
index 293558a5eb7fcc0fbd023b8029542552fb0b0b19..081173d48a9854a24726cd1c0390e138d70a3a48 100644
--- a/source/texk/kpathsea/config.h
+++ b/source/texk/kpathsea/config.h
@@ -1,7 +1,7 @@
 /* config.h: master configuration file, included first by all compilable
    source files (not headers).
 
-   Copyright 1993, 1995, 1996, 1997, 2008, 2010, 2011 Karl Berry.
+   Copyright 1993, 1995, 1996, 1997, 2008, 2010, 2011, 2016 Karl Berry.
    Copyright 2000, 2003, 2004, 2005 Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -95,12 +95,13 @@
   but before "lib.h". FP.
 */
 #if defined (WIN32) || defined (_WIN32)
-#include <kpathsea/knj.h>
 #ifdef __MINGW32__
 #include <kpathsea/mingw32.h>
 #else
 #include <kpathsea/win32lib.h>
 #endif
+#include <kpathsea/types.h>
+#include <kpathsea/knj.h>
 #endif
 
 #if defined(WIN32) || defined(WRAP_SNPRINTF)
diff --git a/source/texk/kpathsea/configure b/source/texk/kpathsea/configure
index 1960d032d009081abb3e40aec3925a68679c34a2..cff68562229c982878b92387513ba7fa33fc4686 100755
--- a/source/texk/kpathsea/configure
+++ b/source/texk/kpathsea/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for Kpathsea 6.2.2.
+# Generated by GNU Autoconf 2.69 for Kpathsea 6.2.3/dev.
 #
 # Report bugs to <tex-k@tug.org>.
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='Kpathsea'
 PACKAGE_TARNAME='kpathsea'
-PACKAGE_VERSION='6.2.2'
-PACKAGE_STRING='Kpathsea 6.2.2'
+PACKAGE_VERSION='6.2.3/dev'
+PACKAGE_STRING='Kpathsea 6.2.3/dev'
 PACKAGE_BUGREPORT='tex-k@tug.org'
 PACKAGE_URL=''
 
@@ -1339,7 +1339,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Kpathsea 6.2.2 to adapt to many kinds of systems.
+\`configure' configures Kpathsea 6.2.3/dev to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1409,7 +1409,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Kpathsea 6.2.2:";;
+     short | recursive ) echo "Configuration of Kpathsea 6.2.3/dev:";;
    esac
   cat <<\_ACEOF
 
@@ -1537,7 +1537,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Kpathsea configure 6.2.2
+Kpathsea configure 6.2.3/dev
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2376,7 +2376,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Kpathsea $as_me 6.2.2, which was
+It was created by Kpathsea $as_me 6.2.3/dev, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2757,14 +2757,14 @@ ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
 
 
 
-KPSEVERSION=6.2.2
+KPSEVERSION=6.2.3/dev
 
 
-KPSE_LT_VERSINFO=8:2:2
+KPSE_LT_VERSINFO=8:3:2
 
 
 
- WEB2CVERSION=" (TeX Live 2016)"
+ WEB2CVERSION=" (TeX Live 2017/dev)"
 
 
 am__api_version='1.15'
@@ -8071,7 +8071,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='kpathsea'
- VERSION='6.2.2'
+ VERSION='6.2.3/dev'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -14695,7 +14695,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by Kpathsea $as_me 6.2.2, which was
+This file was extended by Kpathsea $as_me 6.2.3/dev, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -14761,7 +14761,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-Kpathsea config.status 6.2.2
+Kpathsea config.status 6.2.3/dev
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/source/texk/kpathsea/db.c b/source/texk/kpathsea/db.c
index 2c1ed6344d0cdf10ded01384a9d348e73c3683ac..8a3cf08797b994bd56473705db74e973c9eb2bf6 100644
--- a/source/texk/kpathsea/db.c
+++ b/source/texk/kpathsea/db.c
@@ -1,6 +1,6 @@
 /* db.c: an external database to avoid filesystem lookups.
 
-   Copyright 1994, 1995, 1996, 1997, 2008, 2009, 2011, 2012, 2014 Karl Berry.
+   Copyright 1994, 1995, 1996, 1997, 2008, 2009, 2011, 2012, 2014, 2016 Karl Berry.
    Copyright 1997-2005 Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -106,7 +106,7 @@ db_build (kpathsea kpse, hash_table_type *table,  const_string db_filename)
 
 #if defined(WIN32)
       for (pp = line; *pp; pp++) {
-        if (IS_KANJI(pp))
+        if (kpathsea_IS_KANJI(kpse, pp))
           pp++;
         else
           *pp = TRANSFORM(*pp);
diff --git a/source/texk/kpathsea/doc/kpathsea.info b/source/texk/kpathsea/doc/kpathsea.info
index 61b1f7b294b7a6dad15bbf994cc36b7cb1fb1792..f27eb7381438cade72a3e9bcbf274a5e1159f9e3 100644
--- a/source/texk/kpathsea/doc/kpathsea.info
+++ b/source/texk/kpathsea/doc/kpathsea.info
@@ -1,4 +1,4 @@
-This is kpathsea.info, produced by makeinfo version 6.1 from
+This is kpathsea.info, produced by makeinfo version 5.2 from
 kpathsea.texi.
 
 This file documents the Kpathsea library for path searching.
@@ -37,7 +37,7 @@ Kpathsea library
 ****************
 
 This manual documents the Kpathsea library for path searching.  It
-corresponds to version 6.2.2, released in Aprile 2016.
+corresponds to version 6.2.3dev, released in June 2016.
 
 * Menu:
 
@@ -61,8 +61,8 @@ File: kpathsea.info,  Node: Introduction,  Next: unixtex.ftp,  Prev: Top,  Up: T
 1 Introduction
 **************
 
-This manual corresponds to version 6.2.2 of the Kpathsea library,
-released in Aprile 2016.
+This manual corresponds to version 6.2.3dev of the Kpathsea library,
+released in June 2016.
 
    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
@@ -2805,10 +2805,10 @@ Index
 * --without-mktexpk-default:             mktex configuration. (line  12)
 * --without-mktextfm-default:            mktex configuration. (line  12)
 * -1 debugging value:                    Debugging.           (line  23)
-* -A option to ls:                       ls-R.                (line  33)
+* -A option to 'ls':                     ls-R.                (line  33)
 * -D NUM:                                Path searching options.
                                                               (line  17)
-* -L option to ls:                       ls-R.                (line  38)
+* -L option to 'ls':                     ls-R.                (line  38)
 * . directories, ignored:                ls-R.                (line  33)
 * . files:                               ls-R.                (line  33)
 * .2602gf:                               Unable to generate fonts.
@@ -2894,7 +2894,7 @@ Index
                                                               (line  42)
 * .tex:                                  Supported file formats.
                                                               (line 180)
-* .tex file, included in ls-R:           ls-R.                (line  33)
+* .tex file, included in 'ls-R':         ls-R.                (line  33)
 * .tfm:                                  Supported file formats.
                                                               (line 199)
 * .ttc:                                  Supported file formats.
@@ -2922,7 +2922,7 @@ Index
 * 8.3 filenames, using:                  mktex configuration. (line  68)
 * : may not be ::                        Searching overview.  (line  13)
 * :: expansion:                          Default expansion.   (line   6)
-* \, line continuation in texmf.cnf:     Config files.        (line  37)
+* \, line continuation in 'texmf.cnf':   Config files.        (line  37)
 * \openin:                               Searching overview.  (line  31)
 * \special, suppressing warnings about:  Suppressing warnings.
                                                               (line  31)
@@ -2943,13 +2943,13 @@ Index
 * announcement mailing list:             Mailing lists.       (line   6)
 * API, re-entrant:                       Programming overview.
                                                               (line  16)
-* append-only directories and mktexpk:   Security.            (line  36)
+* append-only directories and 'mktexpk': Security.            (line  36)
 * appendonlydir:                         mktex configuration. (line  60)
-* arguments to mktex:                    mktex script arguments.
+* arguments to 'mktex':                  mktex script arguments.
                                                               (line   6)
 * argv[0]:                               Calling sequence.    (line  14)
 * autoconf, recommended:                 Calling sequence.    (line 117)
-* automounter, and ls-R:                 ls-R.                (line  40)
+* automounter, and 'ls-R':               ls-R.                (line  40)
 * auxiliary tasks:                       Auxiliary tasks.     (line   6)
 * Bach, Johann Sebastian:                Default expansion.   (line  41)
 * backslash-newline:                     Config files.        (line  37)
@@ -2959,7 +2959,7 @@ Index
                                                               (line  30)
 * BIBINPUTS <1>:                         Supported file formats.
                                                               (line 121)
-* blank lines, in texmf.cnf:             Config files.        (line  35)
+* blank lines, in 'texmf.cnf':           Config files.        (line  35)
 * BLTXMLINPUTS:                          Supported file formats.
                                                               (line  34)
 * brace expansion:                       Brace expansion.     (line   6)
@@ -2982,7 +2982,7 @@ Index
 * checksum:                              Suppressing warnings.
                                                               (line  16)
 * circle fonts:                          Fontmap.             (line  19)
-* client_path in kpse->format_info:      Calling sequence.    (line  47)
+* client_path in 'kpse->format_info':    Calling sequence.    (line  47)
 * CLUAINPUTS:                            Supported file formats.
                                                               (line  42)
 * CMAPFONTS:                             Supported file formats.
@@ -2993,7 +2993,7 @@ Index
 * cnf.h:                                 Programming with config files.
                                                               (line  23)
 * comments, in fontmap files:            Fontmap.             (line  27)
-* comments, in texmf.cnf:                Config files.        (line  27)
+* comments, in 'texmf.cnf':              Config files.        (line  27)
 * comments, making:                      Introduction.        (line  28)
 * common features in glyph lookup:       Basic glyph lookup.  (line   6)
 * common problems:                       Common problems.     (line   6)
@@ -3019,8 +3019,9 @@ Index
 * 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 of mktex scripts:        mktex configuration. (line   6)
-* configure options for mktex scripts:   mktex configuration. (line  12)
+* configuration of 'mktex' scripts:      mktex configuration. (line   6)
+* 'configure' options for 'mktex' scripts: mktex configuration.
+                                                              (line  12)
 * context diff:                          Bug checklist.       (line  52)
 * continuation character:                Config files.        (line  37)
 * core dumps, reporting:                 Bug checklist.       (line  58)
@@ -3044,7 +3045,7 @@ Index
 * directory permissions:                 Security.            (line  51)
 * directory structure, for TeX files:    TeX directory structure.
                                                               (line   6)
-* disabling mktex scripts:               mktex configuration. (line   6)
+* disabling 'mktex' scripts:             mktex configuration. (line   6)
 * disk search:                           Searching overview.  (line  22)
 * disk searching, avoiding:              ls-R.                (line  51)
 * disk usage, reducing:                  Logging.             (line   6)
@@ -3071,7 +3072,7 @@ Index
                                                               (line  41)
 * elt-dirs.c <1>:                        Subdirectory expansion.
                                                               (line  48)
-* enabling mktex scripts:                mktex configuration. (line   6)
+* enabling 'mktex' scripts:              mktex configuration. (line   6)
 * ENCFONTS:                              Supported file formats.
                                                               (line  61)
 * engine name:                           Path searching options.
@@ -3098,7 +3099,7 @@ Index
 * extensions, filename:                  File lookup.         (line  24)
 * externally-built filename database:    Filename database.   (line   6)
 * extra colons:                          Default expansion.   (line   6)
-* failed mktex... script invocation:     mktex script names.  (line  35)
+* failed 'mktex...' script invocation:   mktex script names.  (line  35)
 * fallback font:                         Fallback font.       (line   6)
 * fallback resolutions:                  Fallback font.       (line   6)
 * FAQ, Kpathsea:                         Common problems.     (line   6)
@@ -3180,7 +3181,7 @@ Index
                                                               (line 119)
 * interface, not frozen:                 Introduction.        (line  28)
 * introduction:                          Introduction.        (line   6)
-* kdebug::                               Debugging.           (line 105)
+* 'kdebug:':                             Debugging.           (line 105)
 * kdefault.c:                            Default expansion.   (line  48)
 * Knuth, Donald E.:                      History.             (line   6)
 * Knuth, Donald E., archive of programs by: unixtex.ftp.      (line  20)
@@ -3281,9 +3282,9 @@ Index
                                                               (line  20)
 * mkocp:                                 mktex script names.  (line  18)
 * mkofm:                                 mktex script names.  (line  21)
-* mktex script configuration:            mktex configuration. (line   6)
-* mktex script names:                    mktex script names.  (line   6)
-* mktex scripts:                         mktex scripts.       (line   6)
+* 'mktex' script configuration:          mktex configuration. (line   6)
+* 'mktex' script names:                  mktex script names.  (line   6)
+* 'mktex' scripts:                       mktex scripts.       (line   6)
 * mktex.cnf:                             Specially-recognized files.
                                                               (line  28)
 * mktex.cnf <1>:                         mktex configuration. (line  29)
@@ -3293,7 +3294,7 @@ Index
 * mktexfmt:                              mktex script names.  (line  10)
 * mktexmf:                               mktex script names.  (line  15)
 * mktexpk:                               mktex script names.  (line  24)
-* mktexpk can't guess mode:              Unable to generate fonts.
+* 'mktexpk' can't guess mode:            Unable to generate fonts.
                                                               (line  12)
 * mktextex:                              mktex script names.  (line  27)
 * mktextfm:                              mktex script names.  (line  30)
@@ -3314,9 +3315,9 @@ Index
 * MT_FEATURES:                           mktex configuration. (line  39)
 * multiple TeX hierarchies:              Brace expansion.     (line  20)
 * must exist:                            Searching overview.  (line  31)
-* names for mktex scripts:               mktex script names.  (line   6)
+* names for 'mktex' scripts:             mktex script names.  (line   6)
 * Neumann, Gustaf:                       History.             (line  56)
-* NFS and ls-R:                          ls-R.                (line  40)
+* NFS and 'ls-R':                        ls-R.                (line  40)
 * nomfdrivers:                           mktex configuration. (line  92)
 * nomode:                                mktex configuration. (line  97)
 * none:                                  Suppressing warnings.
@@ -3426,7 +3427,7 @@ Index
 * shell variables:                       Variable expansion.  (line  17)
 * shell_escape, example for code:        Programming with config files.
                                                               (line  10)
-* site overrides for mktex...:           mktex configuration. (line  29)
+* site overrides for 'mktex...':         mktex configuration. (line  29)
 * skeleton TeX directory:                TeX directory structure.
                                                               (line   6)
 * slow startup time:                     Slow path searching. (line   6)
@@ -3461,7 +3462,7 @@ Index
                                                               (line   6)
 * symbolic links not found:              Unable to find files.
                                                               (line  21)
-* symbolic links, and ls-R:              ls-R.                (line  38)
+* symbolic links, and 'ls-R':            ls-R.                (line  38)
 * symlinks, resolving:                   Calling sequence.    (line  31)
 * system C compiler bugs:                TeX or Metafont failing.
                                                               (line  19)
@@ -3525,7 +3526,7 @@ Index
                                                               (line   6)
 * texmf.cnf:                             Specially-recognized files.
                                                               (line  38)
-* texmf.cnf missing, warning about:      Config files.        (line  18)
+* '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)
@@ -3569,7 +3570,7 @@ Index
 * tilde.c:                               Tilde expansion.     (line  25)
 * time system call:                      Logging.             (line  15)
 * tolerance for glyph lookup:            Basic glyph lookup.  (line  15)
-* trailing / in home directory:          Tilde expansion.     (line  19)
+* trailing '/' in home directory:        Tilde expansion.     (line  19)
 * trailing colons:                       Default expansion.   (line   6)
 * TRFONTS:                               Supported file formats.
                                                               (line 203)
@@ -3593,7 +3594,7 @@ Index
 * unreadable file warnings:              Suppressing warnings.
                                                               (line  27)
 * unreadable files:                      Searching overview.  (line  56)
-* unusable ls-R warning:                 ls-R.                (line  45)
+* unusable 'ls-R' warning:               ls-R.                (line  45)
 * usage patterns, finding:               Logging.             (line   6)
 * USERPROFILE, as ~ expansion:           Tilde expansion.     (line   6)
 * USE_TEXMFVAR:                          mktex configuration. (line 128)
@@ -3611,8 +3612,8 @@ Index
                                                               (line 219)
 * Vojta, Paul:                           History.             (line  30)
 * Walsh, Norman:                         History.             (line  56)
-* warning about unusable ls-R:           ls-R.                (line  45)
-* warning, about missing texmf.cnf:      Config files.        (line  18)
+* warning about unusable 'ls-R':         ls-R.                (line  45)
+* warning, about missing 'texmf.cnf':    Config files.        (line  18)
 * warnings, file access:                 Searching overview.  (line  56)
 * warnings, suppressing:                 Suppressing warnings.
                                                               (line   6)
@@ -3637,58 +3638,58 @@ Index
 
 Tag Table:
 Node: Top1480
-Node: Introduction2261
-Node: History4208
-Node: unixtex.ftp8805
-Node: Security10300
-Node: TeX directory structure12804
-Node: Path searching16852
-Node: Searching overview17510
-Node: Path sources20905
-Node: Config files21963
-Node: Path expansion25890
-Node: Default expansion26839
-Node: Variable expansion28909
-Node: Tilde expansion30310
-Node: Brace expansion31290
-Node: KPSE_DOT expansion32215
-Node: Subdirectory expansion32728
-Node: Filename database35082
-Node: ls-R36136
-Node: Filename aliases39031
-Node: Database format40209
-Node: Invoking kpsewhich41222
-Node: Path searching options42177
-Node: Specially-recognized files50097
-Node: Auxiliary tasks51452
-Node: Standard options53791
-Node: TeX support54147
-Node: Supported file formats55499
-Node: File lookup63164
-Node: Glyph lookup64913
-Node: Basic glyph lookup66037
-Node: Fontmap66917
-Node: Fallback font69338
-Node: Suppressing warnings70250
-Node: mktex scripts71377
-Node: mktex configuration72592
-Node: mktex script names78395
-Node: mktex script arguments79781
-Node: Programming80660
-Node: Programming overview81182
-Node: Calling sequence83879
-Node: Program-specific files90411
-Node: Programming with config files91434
-Node: Reporting bugs92746
-Node: Bug checklist93424
-Node: Mailing lists96896
-Node: Debugging97571
-Node: Logging102648
-Node: Common problems104515
-Node: Unable to find files104992
-Node: Slow path searching107402
-Node: Unable to generate fonts108777
-Node: TeX or Metafont failing111248
-Node: Index112601
+Node: Introduction2262
+Node: History4210
+Node: unixtex.ftp8807
+Node: Security10302
+Node: TeX directory structure12806
+Node: Path searching16854
+Node: Searching overview17512
+Node: Path sources20907
+Node: Config files21965
+Node: Path expansion25892
+Node: Default expansion26841
+Node: Variable expansion28911
+Node: Tilde expansion30312
+Node: Brace expansion31292
+Node: KPSE_DOT expansion32217
+Node: Subdirectory expansion32730
+Node: Filename database35084
+Node: ls-R36138
+Node: Filename aliases39033
+Node: Database format40211
+Node: Invoking kpsewhich41224
+Node: Path searching options42179
+Node: Specially-recognized files50099
+Node: Auxiliary tasks51454
+Node: Standard options53793
+Node: TeX support54149
+Node: Supported file formats55501
+Node: File lookup63166
+Node: Glyph lookup64915
+Node: Basic glyph lookup66039
+Node: Fontmap66919
+Node: Fallback font69340
+Node: Suppressing warnings70252
+Node: mktex scripts71379
+Node: mktex configuration72594
+Node: mktex script names78397
+Node: mktex script arguments79783
+Node: Programming80662
+Node: Programming overview81184
+Node: Calling sequence83881
+Node: Program-specific files90413
+Node: Programming with config files91436
+Node: Reporting bugs92748
+Node: Bug checklist93426
+Node: Mailing lists96898
+Node: Debugging97573
+Node: Logging102650
+Node: Common problems104517
+Node: Unable to find files104994
+Node: Slow path searching107404
+Node: Unable to generate fonts108779
+Node: TeX or Metafont failing111250
+Node: Index112603
 
 End Tag Table
diff --git a/source/texk/kpathsea/doc/kpathsea.texi b/source/texk/kpathsea/doc/kpathsea.texi
index 6a07df1575b12be302130c8f5815ca6b47bbba7b..71f8ba3726d7c2518b53ada2365b15fd4ac87aad 100644
--- a/source/texk/kpathsea/doc/kpathsea.texi
+++ b/source/texk/kpathsea/doc/kpathsea.texi
@@ -2,8 +2,8 @@
 @setfilename kpathsea.info
 @settitle Kpathsea: A library for path searching
 
-@set version 6.2.2
-@set month-year Aprile 2016
+@set version 6.2.3dev
+@set month-year June 2016
 
 @copying
 This file documents the Kpathsea library for path searching.
diff --git a/source/texk/kpathsea/elt-dirs.c b/source/texk/kpathsea/elt-dirs.c
index 695449469281726e0bd81d22f68faa0b240af486..93041142b107ff4ba2cf5a130a39fc0c01b9eeab 100644
--- a/source/texk/kpathsea/elt-dirs.c
+++ b/source/texk/kpathsea/elt-dirs.c
@@ -1,6 +1,6 @@
 /* elt-dirs.c: Translate a path element to its corresponding director{y,ies}.
 
-   Copyright 1993, 1994, 1995, 1996, 1997, 2008, 2009, 2010, 2011 Karl Berry.
+   Copyright 1993, 1994, 1995, 1996, 1997, 2008, 2009, 2010, 2011, 2016 Karl Berry.
    Copyright 1997, 1998, 1999, 2000, 2005 Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -133,7 +133,7 @@ do_subdir (kpathsea kpse, str_llist_type *str_list_ptr, string elt,
 #if defined (WIN32)
   strcpy(dirname, FN_STRING(name));
   strcat(dirname, "/*.*");         /* "*.*" or "*" -- seems equivalent. */
-  get_wstring_from_fsyscp(dirname, dirnamew);
+  get_wstring_from_mbstring(kpse->File_system_codepage, dirname, dirnamew);
   hnd = FindFirstFileW(dirnamew, &find_file_data);
 
   if (hnd == INVALID_HANDLE_VALUE) {
@@ -158,7 +158,7 @@ do_subdir (kpathsea kpse, str_llist_type *str_list_ptr, string elt,
       int links;
 
       /* Construct the potential subdirectory name.  */
-      potname = get_fsyscp_from_wstring(find_file_data.cFileName, potname=NULL);
+      potname = get_mbstring_from_wstring(kpse->File_system_codepage, find_file_data.cFileName, potname=NULL);
       fn_str_grow (&name, potname);
       free(potname);
 
@@ -368,7 +368,7 @@ kpathsea_normalize_path (kpathsea kpse, string elt)
   for (i = 0; elt[i]; i++) {
     if (elt[i] == '\\')
       elt[i] = '/';
-    else if (IS_KANJI(elt + i))
+    else if (kpathsea_IS_KANJI(kpse, elt + i))
       i++;
   }
 #endif
diff --git a/source/texk/kpathsea/expand.c b/source/texk/kpathsea/expand.c
index d9eadd4bc147541201cc454c4b1e0337e49f4d86..be01fda9ba9b87b21afec93e20633aeab6c1b09b 100644
--- a/source/texk/kpathsea/expand.c
+++ b/source/texk/kpathsea/expand.c
@@ -1,7 +1,7 @@
 /* expand.c: general expansion.
 
    Copyright 1993, 1994, 1995, 1996, 1997, 2005, 2008, 2009, 2011,
-             2012 Karl Berry.
+             2012, 2016 Karl Berry.
    Copyright 1997-2005 Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -226,7 +226,7 @@ kpathsea_path_expand (kpathsea kpse, const_string path)
   for (p = zpath; *p; p++)
     if (*p == '\\')
       *p = '/';
-    else if (IS_KANJI(p))
+    else if (kpathsea_IS_KANJI(kpse, p))
       p++;
 
   ypath = zpath;
@@ -343,7 +343,7 @@ brace_expand (kpathsea kpse, const_string *text)
                 for (p+=2; *p!='}';++p);
         }
 #if defined(WIN32)
-        else if (IS_KANJI(p))
+        else if (kpathsea_IS_KANJI(kpse, p))
             p++;
 #endif
     }
diff --git a/source/texk/kpathsea/find-suffix.c b/source/texk/kpathsea/find-suffix.c
index 3aad8870fe92e164f90eff5517c2e8a5e8a1769f..8d0d92d91071e9a588489900a01cb6366270b67f 100644
--- a/source/texk/kpathsea/find-suffix.c
+++ b/source/texk/kpathsea/find-suffix.c
@@ -1,6 +1,6 @@
 /* find-suffix.c: return the stuff after a dot.
 
-   Copyright 1992, 1993, 1995, 2008, 2011 Karl Berry.
+   Copyright 1992, 1993, 1995, 2008, 2011, 2016 Karl Berry.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -47,10 +47,6 @@ find_suffix (const_string name)
   for (p = dot_pos + 1; *p; p++) {
     if (IS_DIR_SEP (*p))
       return NULL;
-#if defined(WIN32)
-    else if (IS_KANJI(p))
-      p++;
-#endif
   }
 
   return dot_pos + 1;
diff --git a/source/texk/kpathsea/hash.c b/source/texk/kpathsea/hash.c
index 22c2b0806ff51cf2fcc2efb3c9f71880c4365a67..0b126ce836954444e3daeaebfb76cbb64074d2c3 100644
--- a/source/texk/kpathsea/hash.c
+++ b/source/texk/kpathsea/hash.c
@@ -1,6 +1,6 @@
 /* hash.c: hash table operations.
 
-   Copyright 1994-2000, 2002, 2005, 2008, 2012
+   Copyright 1994-2000, 2002, 2005, 2008, 2012, 2016
    Karl Berry & Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -35,7 +35,7 @@ hash (hash_table_type table,  const_string key)
   /* Our keys aren't often anagrams of each other, so no point in
      weighting the characters.  */
   while (*key != 0)
-#if defined(WIN32)
+#if defined (WIN32) && defined (KPSE_COMPAT_API)
     if (IS_KANJI(key)) {
       n = (n + n + (unsigned)(*key++)) % table.size;
       n = (n + n + (unsigned)(*key++)) % table.size;
diff --git a/source/texk/kpathsea/knj.c b/source/texk/kpathsea/knj.c
index 37e1c7589b56f295e31560c3e6118e0c31540def..09d718ce8e2d1c5ecfb6a6f70ef1f1cd077007a8 100644
--- a/source/texk/kpathsea/knj.c
+++ b/source/texk/kpathsea/knj.c
@@ -20,36 +20,15 @@
 #include <kpathsea/debug.h>
 #include <wchar.h>
 
-int is_cp932_system, file_system_codepage;
-
-int isknj(int c)
-{
-  c &= 0xff;
-  switch (is_cp932_system) {
-  case 932:
-    return((c>=0x81 && c<=0x9f) || (c>=0xe0 && c<=0xfc));
-  case 936:
-    return(c>=0x81 && c<=0xfe);
-  case 950:
-    return((c>=0xa1 && c<=0xc6) || (c>=0xc9 && c<=0xf9));
-  default:
-    return(0);
-  }
-}
-
-int isknj2(int c)
+static int
+is_include_space(const char *s)
 {
-  c &= 0xff;
-  switch (is_cp932_system) {
-  case 932:
-    return(c>=0x40 && c<=0xfc && c!=0x7f);
-  case 936:
-    return(c>=0x40 && c<=0xfe && c!=0x7f);
-  case 950:
-    return((c>=0x40 && c<=0x7e) || (c>=0xa1 && c<=0xfe));
-  default:
-    return(0);
-  }
+    char *p;
+    p = strchr(s, ' ');
+    if(p) return 1;
+    p = strchr(s, '\t');
+    if(p) return 1;
+    return 0;
 }
 
 /*
@@ -96,27 +75,55 @@ get_mbstring_from_wstring(int cp, const wchar_t *wstr, char *mbstr)
   return mbstr;
 }
 
+int
+kpathsea_isknj(kpathsea kpse, int c)
+{
+  c &= 0xff;
+  switch (kpse->Is_cp932_system) {
+  case 932:
+    return((c>=0x81 && c<=0x9f) || (c>=0xe0 && c<=0xfc));
+  case 936:
+    return(c>=0x81 && c<=0xfe);
+  case 950:
+    return((c>=0xa1 && c<=0xc6) || (c>=0xc9 && c<=0xf9));
+  default:
+    return(0);
+  }
+}
+
+int
+kpathsea_isknj2(kpathsea kpse, int c)
+{
+  c &= 0xff;
+  switch (kpse->Is_cp932_system) {
+  case 932:
+    return(c>=0x40 && c<=0xfc && c!=0x7f);
+  case 936:
+    return(c>=0x40 && c<=0xfe && c!=0x7f);
+  case 950:
+    return((c>=0x40 && c<=0x7e) || (c>=0xa1 && c<=0xfe));
+  default:
+    return(0);
+  }
+}
+
 /*
   xfopen by file system codepage
 */
 FILE *
-fsyscp_xfopen (const char *filename, const char *mode)
+kpathsea_fsyscp_xfopen (kpathsea kpse, const char *filename, const char *mode)
 {
     FILE *f;
     wchar_t *fnamew, modew[4];
     int i;
-#if defined (KPSE_COMPAT_API)
-    kpathsea kpse;
-#endif
+
     assert(filename && mode);
 
-    fnamew = get_wstring_from_fsyscp(filename, fnamew=NULL);
+    fnamew = get_wstring_from_mbstring(kpse->File_system_codepage, filename, fnamew=NULL);
     for(i=0; (modew[i]=(wchar_t)mode[i]); i++) {} /* mode[i] must be ASCII */
     f = _wfopen(fnamew, modew);
     if (f == NULL)
         FATAL_PERROR(filename);
-#if defined (KPSE_COMPAT_API)
-    kpse = kpse_def;
     if (KPATHSEA_DEBUG_P (KPSE_DEBUG_FOPEN)) {
         DEBUGF_START ();
         fprintf (stderr, "fsyscp_xfopen(%s [", filename);
@@ -128,7 +135,6 @@ fsyscp_xfopen (const char *filename, const char *mode)
 #endif
         DEBUGF_END ();
     }
-#endif
     free(fnamew);
 
     return f;
@@ -138,22 +144,18 @@ fsyscp_xfopen (const char *filename, const char *mode)
   fopen by file system codepage
 */
 FILE *
-fsyscp_fopen (const char *filename, const char *mode)
+kpathsea_fsyscp_fopen (kpathsea kpse, const char *filename, const char *mode)
 {
     FILE *f;
     wchar_t *fnamew, modew[4];
     int i;
-#if defined (KPSE_COMPAT_API)
-    kpathsea kpse;
-#endif
+
     assert(filename && mode);
 
-    fnamew = get_wstring_from_fsyscp(filename, fnamew=NULL);
+    fnamew = get_wstring_from_mbstring(kpse->File_system_codepage, filename, fnamew=NULL);
     for(i=0; (modew[i]=(wchar_t)mode[i]); i++) {} /* mode[i] must be ASCII */
     f = _wfopen(fnamew, modew);
-#if defined (KPSE_COMPAT_API)
     if (f != NULL) {
-        kpse = kpse_def;
         if (KPATHSEA_DEBUG_P (KPSE_DEBUG_FOPEN)) {
             DEBUGF_START ();
             fprintf (stderr, "fsyscp_fopen(%s [", filename);
@@ -166,35 +168,19 @@ fsyscp_fopen (const char *filename, const char *mode)
             DEBUGF_END ();
         }
     }
-#endif
     free(fnamew);
 
     return f;
 }
 
-/*
-  popen by file system codepage
-*/
-static int
-is_include_space(const char *s)
-{
-    char *p;
-    p = strchr(s, ' ');
-    if(p) return 1;
-    p = strchr(s, '\t');
-    if(p) return 1;
-    return 0;
-}
 
 FILE *
-fsyscp_popen (const char *command, const char *mode)
+kpathsea_fsyscp_popen (kpathsea kpse, const char *command, const char *mode)
 {
     FILE *f;
     wchar_t *commandw, modew[4];
     int i;
-#if defined (KPSE_COMPAT_API)
-    kpathsea kpse;
-#endif
+
     assert(command && mode);
 
     if (is_include_space (command)) {
@@ -208,16 +194,15 @@ fsyscp_popen (const char *command, const char *mode)
             *q++ = *p++;
         *q++ = '\"';
         *q = '\0';
-        commandw = get_wstring_from_fsyscp(command2, commandw=NULL);
+        commandw = get_wstring_from_mbstring(kpse->File_system_codepage,command2, commandw=NULL);
         free (command2);
     } else {
-        commandw = get_wstring_from_fsyscp(command, commandw=NULL);
+        commandw = get_wstring_from_mbstring(kpse->File_system_codepage,command, commandw=NULL);
     }
     for(i=0; (modew[i]=(wchar_t)mode[i]); i++) {} /* mode[i] must be ASCII */
     f = _wpopen(commandw, modew);
-#if defined (KPSE_COMPAT_API)
+
     if (f != NULL) {
-        kpse = kpse_def;
         if (KPATHSEA_DEBUG_P (KPSE_DEBUG_FOPEN)) {
             DEBUGF_START ();
             fprintf (stderr, "fsyscp_popen(%s [", command);
@@ -230,7 +215,7 @@ fsyscp_popen (const char *command, const char *mode)
             DEBUGF_END ();
         }
     }
-#endif
+
     free (commandw);
 /* We use always binary mode on Windows */
     if(f) _setmode (fileno (f), _O_BINARY);
@@ -239,7 +224,7 @@ fsyscp_popen (const char *command, const char *mode)
 }
 
 int
-get_command_line_args_utf8 (const_string enc, int *p_ac, char ***p_av)
+kpathsea_get_command_line_args_utf8 (kpathsea kpse, const_string enc, int *p_ac, char ***p_av)
 {
     int argc;
     string *argv;
@@ -258,8 +243,8 @@ get_command_line_args_utf8 (const_string enc, int *p_ac, char ***p_av)
       HANDLE hStderr;
       hStderr = GetStdHandle( STD_ERROR_HANDLE );
 #endif /* DEBUG */
-      file_system_codepage = CP_UTF8;
-      is_cp932_system = 0;
+      kpse->File_system_codepage = CP_UTF8;
+      kpse->Is_cp932_system = 0;
       argvw = CommandLineToArgvW(GetCommandLineW(), &argcw);
       argc = argcw;
       argv = xmalloc(sizeof(char *)*(argcw+1));
@@ -275,7 +260,7 @@ get_command_line_args_utf8 (const_string enc, int *p_ac, char ***p_av)
       argv[argcw] = NULL;
       *p_ac = argc;
       *p_av = argv;
-      return file_system_codepage;
+      return kpse->File_system_codepage;
     } else {
       return 0;
     }
@@ -285,7 +270,7 @@ get_command_line_args_utf8 (const_string enc, int *p_ac, char ***p_av)
   spawnvp by file system codepage
 */
 int
-fsyscp_spawnvp (int mode, const char *command, const char* const *argv)
+kpathsea_fsyscp_spawnvp (kpathsea kpse, int mode, const char *command, const char* const *argv)
 {
     int ret;
     wchar_t *commandw, **argvw, **pw;
@@ -296,11 +281,11 @@ fsyscp_spawnvp (int mode, const char *command, const char* const *argv)
     for (i = 0, p = argv; *p; p++)
       i++;
     argvw = xcalloc (i + 3, sizeof (wchar_t *));
-    commandw = get_wstring_from_fsyscp(command, commandw=NULL);
+    commandw = get_wstring_from_mbstring(kpse->File_system_codepage, command, commandw=NULL);
     p = argv;
     pw = argvw;
     while (*p) {
-      *pw = get_wstring_from_fsyscp(*p, *pw=NULL);
+      *pw = get_wstring_from_mbstring(kpse->File_system_codepage, *p, *pw=NULL);
       p++;
       pw++;
     }
@@ -323,7 +308,7 @@ fsyscp_spawnvp (int mode, const char *command, const char* const *argv)
   system by file system codepage
 */
 int
-fsyscp_system (const char *cmd)
+kpathsea_fsyscp_system (kpathsea kpse, const char *cmd)
 {
     const char *p;
     char  *q;
@@ -353,17 +338,15 @@ fsyscp_system (const char *cmd)
       *q++ = '"';
     *q = '\0';
     av[3] = NULL;
-    ret = fsyscp_spawnvp (_P_WAIT, av[0], (const char* const*) av);
+    ret = kpathsea_fsyscp_spawnvp (kpse, _P_WAIT, av[0], (const char* const*) av);
     free (av[0]);
     free (av[1]);
     free (av[2]);
     return ret;
 }
 
-static int getc_len;
-static int getc_buff[4];
-
-int win32_getc(FILE *fp)
+int
+kpathsea_win32_getc(kpathsea kpse, FILE *fp)
 {
     const int fd = fileno(fp);
     HANDLE hStdin;
@@ -371,17 +354,16 @@ int win32_getc(FILE *fp)
     wchar_t wc[3];
     char mbc[5];
     int j;
-    static wchar_t wcbuf = L'\0';
 
-    if (!(fd == fileno(stdin) && _isatty(fd) && file_system_codepage == CP_UTF8))
+    if (!(fd == fileno(stdin) && _isatty(fd) && kpse->File_system_codepage == CP_UTF8))
         return getc(fp);
 
-    if (getc_len == 0)
+    if (kpse->getc_len == 0)
     {
         hStdin = GetStdHandle(STD_INPUT_HANDLE);
-        if (wcbuf) {
-            wc[0] = wcbuf;
-            wcbuf = L'\0';
+        if (kpse->wcbuf) {
+            wc[0] = kpse->wcbuf;
+            kpse->wcbuf = L'\0';
         }
         else if (ReadConsoleW(hStdin, wc, 1, &ret, NULL) == 0)
             return EOF;
@@ -391,7 +373,7 @@ int win32_getc(FILE *fp)
             if (0xdc00<=wc[1] && wc[1]<0xe000) {
                 wc[2]=L'\0';
             } else {
-                wcbuf=wc[1];
+                kpse->wcbuf=wc[1];
                 wc[0]=0xfffd;    /* illegal surrogate pair */
                 wc[1]=L'\0';
             }
@@ -404,21 +386,22 @@ int win32_getc(FILE *fp)
         get_utf8_from_wstring(wc,mbc);
         j=strlen(mbc)-1;
         while(j>=0) {
-            getc_buff[getc_len++]=(int)mbc[j--];
+            kpse->getc_buff[kpse->getc_len++]=(int)mbc[j--];
         }
     }
-    return getc_buff[--getc_len];
+    return kpse->getc_buff[--kpse->getc_len];
 }
 
-int win32_ungetc(int c, FILE *fp)
+int
+kpathsea_win32_ungetc(kpathsea kpse, int c, FILE *fp)
 {
     const int fd = fileno(fp);
 
-    if (!(fd == fileno(stdin) && _isatty(fd) && file_system_codepage == CP_UTF8))
+    if (!(fd == fileno(stdin) && _isatty(fd) && kpse->File_system_codepage == CP_UTF8))
         return ungetc(c, fp);
 
-    assert(getc_len < 4);
-    return getc_buff[getc_len++] = c;
+    assert(kpse->getc_len < 4);
+    return kpse->getc_buff[kpse->getc_len++] = c;
 }
 
 static int __win32_fputs(const char *str, HANDLE hStdout)
@@ -437,13 +420,14 @@ static int __win32_fputs(const char *str, HANDLE hStdout)
     return ret;
 }
 
-int win32_fputs(const char *str, FILE *fp)
+int
+kpathsea_win32_fputs(kpathsea kpse, const char *str, FILE *fp)
 {
     const int fd = fileno(fp);
     HANDLE hStdout;
 
     if (!((fd == fileno(stdout) || fd == fileno(stderr)) && _isatty(fd)
-        && file_system_codepage == CP_UTF8))
+        && kpse->File_system_codepage == CP_UTF8))
         return fputs(str, fp);
 
     hStdout = (fd == fileno(stdout)) ?
@@ -454,7 +438,8 @@ int win32_fputs(const char *str, FILE *fp)
 
 #define MAX_PROMPT_STR_SIZE 8192
 
-int win32_vfprintf(FILE *fp, const char *format, va_list argp)
+int
+kpathsea_win32_vfprintf(kpathsea kpse, FILE *fp, const char *format, va_list argp)
 {
     const int fd = fileno(fp);
     HANDLE hStdout;
@@ -462,7 +447,7 @@ int win32_vfprintf(FILE *fp, const char *format, va_list argp)
     int ret;
 
     if (!((fd == fileno(stdout) || fd == fileno(stderr)) && _isatty(fd)
-        && file_system_codepage == CP_UTF8))
+        && kpse->File_system_codepage == CP_UTF8))
         return vfprintf(fp, format, argp);
 
     hStdout = (fd == fileno(stdout)) ?
@@ -475,25 +460,25 @@ int win32_vfprintf(FILE *fp, const char *format, va_list argp)
     return ret;
 }
 
-int win32_puts(const char *str)
+int
+kpathsea_win32_puts(kpathsea kpse, const char *str)
 {
-    if (win32_fputs(str, stdout)==EOF) {
+    if (kpathsea_win32_fputs(kpse, str, stdout)==EOF) {
         return EOF;
     }
     return puts("");
 }
 
-int win32_putc(int c, FILE *fp)
+int
+kpathsea_win32_putc(kpathsea kpse, int c, FILE *fp)
 {
     const int fd = fileno(fp);
     HANDLE hStdout;
     DWORD ret;
     wchar_t wstr[3];
-    static int len = 0;
-    static char buff[5], *str;
 
     if (!((fd == fileno(stdout) || fd == fileno(stderr)) && _isatty(fd)
-        && file_system_codepage == CP_UTF8))
+        && kpse->File_system_codepage == CP_UTF8))
         return putc(c, fp);
 
     hStdout = (fd == fileno(stdout)) ?
@@ -502,31 +487,158 @@ int win32_putc(int c, FILE *fp)
     c &= 0xff;
 
     if (c < 0x80) {
-        str = buff;
-        len = 1;
+        kpse->st_str = kpse->st_buff;
+        kpse->st_len = 1;
     }
     if (c < 0xc0) { /* ASCII or trailer */
-        *str++ = c;
-        len--;
-        if (len == 0) {
-            *str = '\0';
-            get_wstring_from_utf8(buff, wstr);
+        *(kpse->st_str)++ = c;
+        kpse->st_len--;
+        if (kpse->st_len == 0) {
+            *(kpse->st_str) = '\0';
+            get_wstring_from_utf8(kpse->st_buff, wstr);
             if (WriteConsoleW(hStdout, wstr, wcslen(wstr), &ret, NULL) == 0) {
-                len = 0;
+                kpse->st_len = 0;
                 return EOF;
             }
         }
-        else if (len < 0) return EOF;
+        else if (kpse->st_len < 0) return EOF;
         return c;
     }
-    else if (c < 0xc2) { len = 0; return EOF; }  /* illegal */
-    else if (c < 0xe0) len = 2;
-    else if (c < 0xf0) len = 3;
-    else if (c < 0xf5) len = 4;
-    else { len = 0; return EOF; }
-
-    str = buff;
-    *str++ = c;
-    len--;
+    else if (c < 0xc2) { kpse->st_len = 0; return EOF; }  /* illegal */
+    else if (c < 0xe0) kpse->st_len = 2;
+    else if (c < 0xf0) kpse->st_len = 3;
+    else if (c < 0xf5) kpse->st_len = 4;
+    else { kpse->st_len = 0; return EOF; }
+
+    kpse->st_str = kpse->st_buff;
+    *(kpse->st_str)++ = c;
+    kpse->st_len--;
     return c;
 }
+
+int
+kpathsea_IS_KANJI(kpathsea kpse, const char *p)
+{
+  int ret;
+
+  ret = kpse->Is_cp932_system && kpathsea_isknj(kpse, *(p)) &&
+        kpathsea_isknj2(kpse, *(p+1));
+  return ret;
+}
+
+char *
+kpathsea_get_fsyscp_from_wstring(kpathsea kpse, const wchar_t *w,char *mb)
+{
+  return get_mbstring_from_wstring(kpse->File_system_codepage, w, mb);
+}
+
+wchar_t *
+kpathsea_get_wstring_from_fsyscp(kpathsea kpse, const char *mb,wchar_t *w)
+{
+  return get_wstring_from_mbstring(kpse->File_system_codepage, mb, w);
+}
+
+#if defined (KPSE_COMPAT_API)
+
+int
+isknj(int c)
+{
+  return kpathsea_isknj(kpse_def, c);
+}
+
+int
+isknj2(int c)
+{
+  return kpathsea_isknj2(kpse_def, c);
+}
+
+FILE *
+fsyscp_xfopen (const char *filename, const char *mode)
+{
+  return kpathsea_fsyscp_xfopen (kpse_def, filename, mode);
+}
+
+FILE *
+fsyscp_fopen (const char *filename, const char *mode)
+{
+  return kpathsea_fsyscp_fopen (kpse_def, filename, mode);
+}
+
+FILE *
+fsyscp_popen (const char *command, const char *mode)
+{
+  return kpathsea_fsyscp_popen (kpse_def, command, mode);
+}
+
+int
+get_command_line_args_utf8 (const_string enc, int *p_ac, char ***p_av)
+{
+  return kpathsea_get_command_line_args_utf8 (kpse_def, enc, p_ac, p_av);
+}
+
+int
+fsyscp_spawnvp (int mode, const char *command, const char* const *argv)
+{
+  return kpathsea_fsyscp_spawnvp (kpse_def, mode, command, argv);
+}
+
+int
+fsyscp_system (const char *cmd)
+{
+  return kpathsea_fsyscp_system (kpse_def, cmd);
+}
+
+int
+win32_getc(FILE *fp)
+{
+  return kpathsea_win32_getc(kpse_def, fp);
+}
+
+int
+win32_ungetc(int c, FILE *fp)
+{
+  return kpathsea_win32_ungetc(kpse_def, c, fp);
+}
+
+int
+win32_fputs(const char *str, FILE *fp)
+{
+  return kpathsea_win32_fputs(kpse_def, str, fp);
+}
+
+int
+win32_vfprintf(FILE *fp, const char *format, va_list argp)
+{
+  return kpathsea_win32_vfprintf(kpse_def, fp, format, argp);
+}
+
+int
+win32_puts(const char *str)
+{
+  return kpathsea_win32_puts(kpse_def, str);
+}
+
+int
+win32_putc(int c, FILE *fp)
+{
+  return kpathsea_win32_putc(kpse_def, c, fp);
+}
+
+int
+IS_KANJI(const char *p)
+{
+  return kpathsea_IS_KANJI(kpse_def, p);
+}
+
+char *
+get_fsyscp_from_wstring(const wchar_t *w,char *mb)
+{
+  return kpathsea_get_fsyscp_from_wstring(kpse_def, w, mb);
+}
+
+wchar_t *
+get_wstring_from_fsyscp(const char *mb,wchar_t *w)
+{
+  return kpathsea_get_wstring_from_fsyscp(kpse_def, mb, w);
+}
+#endif
diff --git a/source/texk/kpathsea/knj.h b/source/texk/kpathsea/knj.h
index fc1b808b2311e0d4170bcd86f6a1521ac5b0edab..5387533de1af5550a848165f76ce6a51464eb4b1 100644
--- a/source/texk/kpathsea/knj.h
+++ b/source/texk/kpathsea/knj.h
@@ -1,6 +1,6 @@
 /* knj.h: check for 2-Byte Kanji (CP 932, SJIS) codes.
 
-   Copyright 2010, 2014 Akira Kakuto.
+   Copyright 2010, 2014, 2016 Akira Kakuto.
    Copyright 2013, 2014 TANAKA Takuji.
 
    This library is free software; you can redistribute it and/or
@@ -23,14 +23,32 @@
 extern "C" {
 #endif
 
-extern KPSEDLL int is_cp932_system;
-extern KPSEDLL int file_system_codepage;
+extern KPSEDLL wchar_t* get_wstring_from_mbstring(int cp, const char *mbstr, wchar_t *wstr);
+extern KPSEDLL char* get_mbstring_from_wstring(int cp, const wchar_t *wstr, char *mbstr);
+extern KPSEDLL int kpathsea_isknj(kpathsea kpse, int c);
+extern KPSEDLL int kpathsea_isknj2(kpathsea kpse, int c);
+extern KPSEDLL FILE* kpathsea_fsyscp_xfopen(kpathsea kpse, const char *filename, const char *mode);
+extern KPSEDLL FILE* kpathsea_fsyscp_fopen(kpathsea kpse, const char *filename, const char *mode);
+extern KPSEDLL FILE* kpathsea_fsyscp_popen(kpathsea kpse, const char *command, const char *mode);
+extern KPSEDLL int kpathsea_fsyscp_spawnvp(kpathsea kpse, int mode, const char *command, const char* const *argv);
+extern KPSEDLL int kpathsea_fsyscp_system(kpathsea kpse, const char *cmd);
+extern KPSEDLL int kpathsea_get_command_line_args_utf8(kpathsea kpse, const char *enc, int *p_ac, char ***p_av);
+extern KPSEDLL int kpathsea_win32_getc(kpathsea kpse, FILE *fp);
+extern KPSEDLL int kpathsea_win32_ungetc(kpathsea kpse, int c, FILE *fp);
+extern KPSEDLL int kpathsea_win32_fputs(kpathsea kpse, const char *str, FILE *fp);
+extern KPSEDLL int kpathsea_win32_puts(kpathsea kpse, const char *str);
+extern KPSEDLL int kpathsea_win32_vfprintf(kpathsea kpse, FILE *fp, const char *format, va_list argp);
+extern KPSEDLL int kpathsea_win32_putc(kpathsea kpse, int c, FILE *fp);
+extern KPSEDLL int kpathsea_IS_KANJI(kpathsea kpse, const char *p);
+extern KPSEDLL char *kpathsea_get_fsyscp_from_wstring(kpathsea kpse, const wchar_t *w,char *mb);
+extern KPSEDLL wchar_t *kpathsea_get_wstring_from_fsyscp(kpathsea kpse, const char *mb,wchar_t *w);
+
+#if defined (KPSE_COMPAT_API)
+#define is_cp932_system kpse_def->Is_cp932_system
+#define file_system_codepage kpse_def->File_system_codepage
 
 extern KPSEDLL int isknj(int c);
 extern KPSEDLL int isknj2(int c);
-
-extern KPSEDLL wchar_t* get_wstring_from_mbstring(int cp, const char *mbstr, wchar_t *wstr);
-extern KPSEDLL char* get_mbstring_from_wstring(int cp, const wchar_t *wstr, char *mbstr);
 extern KPSEDLL FILE* fsyscp_xfopen(const char *filename, const char *mode);
 extern KPSEDLL FILE* fsyscp_fopen(const char *filename, const char *mode);
 extern KPSEDLL FILE* fsyscp_popen(const char *command, const char *mode);
@@ -43,21 +61,17 @@ extern KPSEDLL int win32_fputs(const char *str, FILE *fp);
 extern KPSEDLL int win32_puts(const char *str);
 extern KPSEDLL int win32_vfprintf(FILE *fp, const char *format, va_list argp);
 extern KPSEDLL int win32_putc(int c, FILE *fp);
-
+extern KPSEDLL int IS_KANJI(const char *p);
+extern KPSEDLL char *get_fsyscp_from_wstring(const wchar_t *w,char *mb);
+extern KPSEDLL wchar_t *get_wstring_from_fsyscp(const char *mb,wchar_t *w);
+#endif
 #ifdef __cplusplus
 }
 #endif
 
-/* True if P points to a 2-Byte Kanji (CP 932, SJIS) code.  */
-#define IS_KANJI(p) is_cp932_system && isknj(*(p)) && isknj2(*(p+1))
-
 /* Get wide string from multibyte string in UTF-8 */
 #define get_wstring_from_utf8(mb,w) get_wstring_from_mbstring(CP_UTF8,mb,w)
 /* Get multibyte string in UTF-8 from wide string */
 #define get_utf8_from_wstring(w,mb) get_mbstring_from_wstring(CP_UTF8,w,mb)
-/* Get wide string from multibyte string in file system codepage */
-#define get_wstring_from_fsyscp(mb,w) get_wstring_from_mbstring(file_system_codepage,mb,w)
-/* Get multibyte string in file system codepage from wide string */
-#define get_fsyscp_from_wstring(w,mb) get_mbstring_from_wstring(file_system_codepage,w,mb)
 
 #endif /* not KPATHSEA_KNJ_H */
diff --git a/source/texk/kpathsea/kpsewhich.c b/source/texk/kpathsea/kpsewhich.c
index b26bd4f68bbfc77b24a19f6505f7522ed3be62e2..81db2b50845580acfc9fa1c0b57956616bc63f93 100644
--- a/source/texk/kpathsea/kpsewhich.c
+++ b/source/texk/kpathsea/kpsewhich.c
@@ -30,13 +30,6 @@
 #include <kpathsea/variable.h>
 #include <kpathsea/version.h>
 
-#ifdef WIN32
-#undef fputs
-#undef puts
-#define fputs win32_fputs
-#define puts  win32_puts
-#endif
-
 /* For variable and path expansion.  (-expand-var, -expand-path,
    -show-path) */
 string var_to_expand = NULL;
@@ -272,25 +265,24 @@ find_format (kpathsea kpse, string name, boolean is_filename)
    We don't reallocate the actual strings, just the list elements.
    Perhaps later we will implement wildcards or // or something.  */
 
+#if defined(WIN32)
 static string *
-subdir_match (str_list_type subdirs,  string *matches)
+kpathsea_subdir_match (kpathsea kpse, str_list_type subdirs,  string *matches)
 {
   string *ret = XTALLOC1 (string);
   unsigned len = 1;
   unsigned e;
   unsigned m;
-#if defined(WIN32)
   string p;
 
   for (e = 0; e < STR_LIST_LENGTH (subdirs); e++) {
     for (p = STR_LIST_ELT (subdirs, e); *p; p++) {
       if (*p == '\\')
         *p = '/';
-      else if (IS_KANJI(p))
+      else if (kpathsea_IS_KANJI(kpse, p))
         p++;
     }
   }
-#endif
 
   for (m = 0; matches[m]; m++) {
     unsigned loc;
@@ -322,6 +314,45 @@ subdir_match (str_list_type subdirs,  string *matches)
   return ret;
 }
 
+#else /* WIN32 */
+static string *
+subdir_match (str_list_type subdirs,  string *matches)
+{
+  string *ret = XTALLOC1 (string);
+  unsigned len = 1;
+  unsigned e;
+  unsigned m;
+
+  for (m = 0; matches[m]; m++) {
+    unsigned loc;
+    string s = xstrdup (matches[m]);
+    for (loc = strlen (s); loc > 0 && !IS_DIR_SEP_CH (s[loc-1]); loc--)
+      ;
+    while (loc > 0 && IS_DIR_SEP_CH (s[loc-1])) {
+      loc--;
+    }
+    s[loc] = 0;  /* wipe out basename */
+
+    for (e = 0; e < STR_LIST_LENGTH (subdirs); e++) {
+      string subdir = STR_LIST_ELT (subdirs, e);
+      unsigned subdir_len = strlen (subdir);
+      while (subdir_len > 0 && IS_DIR_SEP_CH (subdir[subdir_len-1])) {
+        subdir_len--;
+        subdir[subdir_len] = 0; /* remove trailing slashes from subdir spec */
+      }
+      if (FILESTRCASEEQ (subdir, s + loc - subdir_len)) {
+        /* matched, save this one.  */
+        XRETALLOC (ret, len + 1, string);
+        ret[len-1] = matches[m];
+        len++;
+      }
+    }
+    free (s);
+  }
+  ret[len-1] = NULL;
+  return ret;
+}
+#endif /* WIN32 */
 
 
 /* Look up a single filename NAME.  Return 0 if success, 1 if failure.  */
@@ -395,7 +426,11 @@ lookup (kpathsea kpse, string name)
 
   /* Filter by subdirectories, if specified.  */
   if (STR_LIST_LENGTH (subdir_paths) > 0) {
+#if defined(WIN32)
+    string *new_list = kpathsea_subdir_match (kpse, subdir_paths, ret_list);
+#else
     string *new_list = subdir_match (subdir_paths, ret_list);
+#endif /* WIN32 */
     free (ret_list);
     ret_list = new_list;
   }
@@ -403,7 +438,11 @@ lookup (kpathsea kpse, string name)
   /* Print output.  */
   if (ret_list) {
     for (i = 0; ret_list[i]; i++)
+#ifdef WIN32
+      kpathsea_win32_puts (kpse, ret_list[i]);
+#else
       puts (ret_list[i]);
+#endif
     /* Save whether we found anything */
     ret = ret_list[0];
     free (ret_list);
@@ -493,7 +532,11 @@ help_formats (kpathsea kpse, string *argv)
     putchar (':');
     for (ext = kpse->format_info[f].suffix; ext && *ext; ext++) {
       putchar (' ');
+#ifdef WIN32
+      kpathsea_win32_fputs (kpse, *ext, stdout);
+#else
       fputs (*ext, stdout);
+#endif
     }
 
     if (kpse->format_info[f].alt_suffix) {
@@ -502,7 +545,11 @@ help_formats (kpathsea kpse, string *argv)
     }
     for (ext = kpse->format_info[f].alt_suffix; ext && *ext; ext++) {
       putchar (' ');
+#ifdef WIN32
+      kpathsea_win32_fputs (kpse, *ext, stdout);
+#else
       fputs (*ext, stdout);
+#endif
     }
 
     printf ("  [variables: %s]\n", envvar_list);
@@ -720,7 +767,7 @@ main (int argc,  string *argv)
       enc = "utf-8";
     else
       enc = kpathsea_var_value (kpse, "command_line_encoding");
-    if (get_command_line_args_utf8(enc, &ac, &av)) {
+    if (kpathsea_get_command_line_args_utf8(kpse, enc, &ac, &av)) {
       optind = 0;
       read_command_line (kpse, ac, av);
       argv = av;
@@ -735,22 +782,38 @@ main (int argc,  string *argv)
 
   /* Variable expansion.  */
   if (var_to_expand)
+#ifdef WIN32
+    kpathsea_win32_puts (kpse, kpathsea_var_expand (kpse, var_to_expand));
+#else
     puts (kpathsea_var_expand (kpse, var_to_expand));
+#endif
 
   /* Brace expansion. */
   if (braces_to_expand)
+#ifdef WIN32
+    kpathsea_win32_puts (kpse, kpathsea_brace_expand (kpse, braces_to_expand));
+#else
     puts (kpathsea_brace_expand (kpse, braces_to_expand));
+#endif
 
   /* Path expansion. */
   if (path_to_expand)
+#ifdef WIN32
+    kpathsea_win32_puts (kpse, kpathsea_path_expand (kpse, path_to_expand));
+#else
     puts (kpathsea_path_expand (kpse, path_to_expand));
+#endif
 
   /* Show a search path. */
   if (path_to_show) {
     if (user_format != kpse_last_format) {
       if (!kpse->format_info[user_format].type) /* needed if arg was numeric */
         kpathsea_init_format (kpse, user_format);
+#ifdef WIN32
+      kpathsea_win32_puts (kpse, kpse->format_info[user_format].path);
+#else
       puts (kpse->format_info[user_format].path);
+#endif
     } else {
       WARNING ("kpsewhich: Cannot show path for unknown file type");
     }
@@ -763,7 +826,11 @@ main (int argc,  string *argv)
       unfound++;
       value = "";
     }
+#ifdef WIN32
+    kpathsea_win32_puts (kpse, value);
+#else
     puts (value);
+#endif
   }
 
   if (safe_in_name) {
diff --git a/source/texk/kpathsea/make-suffix.c b/source/texk/kpathsea/make-suffix.c
index 9264aaeb405d4ec0f1f41f2457cb9c719bb86a43..16231bb1ad50afaf2a19153e82e9fbac407e1261 100644
--- a/source/texk/kpathsea/make-suffix.c
+++ b/source/texk/kpathsea/make-suffix.c
@@ -1,6 +1,6 @@
 /* make-suffix.c: unconditionally add a filename suffix.
 
-   Copyright 1992, 1993, 1995, 2008, 2011 Karl Berry.
+   Copyright 1992, 1993, 1995, 2008, 2011, 2016 Karl Berry.
    Copyright 2001, 2005 Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -38,7 +38,7 @@ make_suffix (const_string s,  const_string suffix)
         dot_pos = NULL;
         break;
       }
-#if defined(WIN32)
+#if defined(WIN32) && defined(KPSE_COMPAT_API)
       else if (IS_KANJI(p))
         p++;
 #endif
@@ -59,8 +59,10 @@ make_suffix (const_string s,  const_string suffix)
   for (q = new_s; *q; q++) {
     if (*q == '\\')
       *q = '/';
+#if defined(KPSE_COMPAT_API)
     else if (IS_KANJI(q))
       q++;
+#endif
   }
 #endif
 
diff --git a/source/texk/kpathsea/path-elt.c b/source/texk/kpathsea/path-elt.c
index b40032ecd4c9ad2436cea33c006cee425d146af9..b678bdf4cf256e89e65a1ca85eaf7f792c9a76e0 100644
--- a/source/texk/kpathsea/path-elt.c
+++ b/source/texk/kpathsea/path-elt.c
@@ -1,6 +1,6 @@
 /* path-elt.c: return the stuff between colons.
 
-   Copyright 1993, 1996 2008 Karl Berry.
+   Copyright 1993, 1996 2008, 2016 Karl Berry.
    Copyright 1997, 2001, 2005 Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -56,7 +56,7 @@ element (kpathsea kpse, const_string passed_path,  boolean env_p)
     if (*p == '{') ++brace_level;
     else if (*p == '}') --brace_level;
 #if defined(WIN32)
-    else if (IS_KANJI(p))
+    else if (kpathsea_IS_KANJI(kpse, p))
         p++;
 #endif
     p++;
diff --git a/source/texk/kpathsea/progname.c b/source/texk/kpathsea/progname.c
index c4fe781011cba9626b6f575c371d4cece0cf67db..fa4a7764334f77d83388cdbd69987f1b85a71568 100644
--- a/source/texk/kpathsea/progname.c
+++ b/source/texk/kpathsea/progname.c
@@ -1,6 +1,6 @@
 /* progname.c: the executable name we were invoked as; general initialization.
 
-   Copyright 1994, 1996, 1997, 2008-2013 Karl Berry.
+   Copyright 1994, 1996, 1997, 2008-2013, 2016 Karl Berry.
    Copyright 1998-2005 Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -501,14 +501,14 @@ kpathsea_set_program_name (kpathsea kpse,  const_string argv0,
   }
 
 #if defined(WIN32)
-  if (!file_system_codepage)
-    file_system_codepage = AreFileApisANSI() ? GetACP() : GetOEMCP();
-  cp = file_system_codepage;
+  if (!kpse->File_system_codepage)
+    kpse->File_system_codepage = AreFileApisANSI() ? GetACP() : GetOEMCP();
+  cp = kpse->File_system_codepage;
   if (cp == 932 || cp == 936 || cp == 950) {
-    is_cp932_system = cp;
+    kpse->Is_cp932_system = cp;
   }
   else
-    is_cp932_system = 0;
+    kpse->Is_cp932_system = 0;
 
 #if defined(__MINGW32__)
   /* Set various info about user. Among many things,
@@ -585,7 +585,7 @@ kpathsea_set_program_name (kpathsea kpse,  const_string argv0,
     for (fp = path; fp && *fp; fp++)
         if (IS_DIR_SEP(*fp)) *fp = DIR_SEP;
 #else /* !__MINGW32__ */
-    if (getlongpath(path, short_path, PATH_MAX) == 0)
+    if (kpathsea_getlongpath(kpse, path, short_path, PATH_MAX) == 0)
         FATAL1("Can't get long name for %s.\n", short_path);
     if ((hnd = FindFirstFile(short_path, &ffd)) == INVALID_HANDLE_VALUE)
         FATAL1("The following path points to an invalid file : %s\n", path);
diff --git a/source/texk/kpathsea/readable.c b/source/texk/kpathsea/readable.c
index 3e604cd9c05398e510f8893fcd1afb5b1e6b2347..0afdd6a2465fb2f7768629d6d162ee521d677dfc 100644
--- a/source/texk/kpathsea/readable.c
+++ b/source/texk/kpathsea/readable.c
@@ -1,6 +1,6 @@
 /* readable.c: check if a filename is a readable non-directory file.
 
-   Copyright 1993, 1995, 1996, 2008, 2011, 2012 Karl Berry.
+   Copyright 1993, 1995, 1996, 2008, 2011, 2012, 2016 Karl Berry.
    Copyright 1998, 1999, 2000, 2001, 2005 Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -38,10 +38,10 @@
 #elif defined (WIN32)
 /* st must be an unsigned int under Windows */
 static boolean
-READABLE(const_string fn, unsigned int st)
+READABLE(kpathsea kpse, const_string fn, unsigned int st)
 {
   wchar_t *fnw;
-  fnw = get_wstring_from_fsyscp(fn, fnw=NULL);
+  fnw = get_wstring_from_mbstring(kpse->File_system_codepage, fn, fnw=NULL);
   if ((st = GetFileAttributesW(fnw)) != 0xFFFFFFFF) {
       /* succeeded */
       errno = 0;
@@ -82,7 +82,11 @@ kpathsea_readable_file (kpathsea kpse, string name)
 #endif
 
   kpathsea_normalize_path (kpse, name);
+#ifdef WIN32
+  if (READABLE (kpse, name, st)) {
+#else
   if (READABLE (name, st)) {
+#endif
       return name;
 #ifdef ENAMETOOLONG
   } else if (errno == ENAMETOOLONG) {
@@ -95,7 +99,7 @@ kpathsea_readable_file (kpathsea kpse, string name)
           if (c_len <= NAME_MAX)
               t = s;
 #if defined(WIN32)
-          if (IS_KANJI (s)) {
+          if (kpathsea_IS_KANJI (kpse, s)) {
               s++;
               c_len += 2;
               continue;
@@ -118,7 +122,11 @@ kpathsea_readable_file (kpathsea kpse, string name)
 
       /* Perhaps some other error will occur with the truncated name, so
          let's call access again.  */
+#ifdef WIN32
+      if (READABLE (kpse, name, st)) /* Success.  */
+#else
       if (READABLE (name, st)) /* Success.  */
+#endif
           return name;
 #endif /* ENAMETOOLONG */
   } else { /* Some other error.  */
diff --git a/source/texk/kpathsea/tex-file.c b/source/texk/kpathsea/tex-file.c
index 4dcade9f56655d34a8c67c59e7a444ffd54b6c41..0b008ac443ed5b1d073acf56c8aa8b0e06868d8a 100644
--- a/source/texk/kpathsea/tex-file.c
+++ b/source/texk/kpathsea/tex-file.c
@@ -1304,7 +1304,7 @@ executable_filep (kpathsea kpse, const_string fname, boolean silent)
       pp = kpse->suffixlist;
       if (pp && q) {
         while (*pp) {
-          if (strchr (fname, ':') || !strcmp (q, *pp)) {
+          if (!strcmp (q, *pp)) {
             if (!silent)
               fprintf (stderr, "\n%s: Forbidden to open for writing\n", fname);
             free (base);
diff --git a/source/texk/kpathsea/tilde.c b/source/texk/kpathsea/tilde.c
index fa7ebf96b5fe82e26c1c24aea046db5dedb2a5d5..98cc93e79b22e51575ec218d5c79f09c799bc692 100644
--- a/source/texk/kpathsea/tilde.c
+++ b/source/texk/kpathsea/tilde.c
@@ -1,7 +1,7 @@
 /* tilde.c: expand user's home directories.
 
     Copyright 1997, 1998, 2005, Olaf Weber.
-    Copyright 1993, 1995, 1996, 1997, 2008, 2011 Karl Berry.
+    Copyright 1993, 1995, 1996, 1997, 2008, 2011, 2016 Karl Berry.
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Lesser General Public
@@ -88,7 +88,7 @@ kpathsea_tilde_expand (kpathsea kpse, string name)
       c = 2;
       while (!IS_DIR_SEP (name[c]) && name[c] != 0) {  /* find user name */
 #if defined(WIN32)
-        if (IS_KANJI(name+c))
+        if (kpathsea_IS_KANJI(kpse, name+c))
           c++;
 #endif
         c++;
@@ -130,7 +130,7 @@ kpathsea_tilde_expand (kpathsea kpse, string name)
       for (q = home; *q; q++) {
         if (IS_DIR_SEP (*q) && q[1] == 0)
           c++;
-        else if (IS_KANJI(q))
+        else if (kpathsea_IS_KANJI(kpse, q))
           q++;
       }
 #else
@@ -146,7 +146,7 @@ kpathsea_tilde_expand (kpathsea kpse, string name)
   for (p = expansion; *p; p++) {
     if (*p == '\\')
       *p = '/'; 
-    else if (IS_KANJI(p))
+    else if (kpathsea_IS_KANJI(kpse, p))
       p++;
   }
 #endif
diff --git a/source/texk/kpathsea/types.h b/source/texk/kpathsea/types.h
index 54fd59c604ed6b558fa5a22852a4426934b986a7..081202a2f63aabd4f0271b4983b432cfc81ef848 100644
--- a/source/texk/kpathsea/types.h
+++ b/source/texk/kpathsea/types.h
@@ -1,6 +1,6 @@
 /* types.h: general types for kpathsea.
 
-   Copyright 1993, 1995, 1996, 2005, 2008-2014 Karl Berry.
+   Copyright 1993, 1995, 1996, 2005, 2008-2014, 2016 Karl Berry.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -292,6 +292,16 @@ typedef struct kpathsea_instance {
     struct passwd the_passwd;
     int __system_allow_multiple_cmds;
 #endif /* WIN32 && !__MINGW32__ */
+#if defined(WIN32)
+    int Is_cp932_system;
+    int File_system_codepage;
+    int getc_len;
+    int getc_buff[4];
+    wchar_t wcbuf;
+    int st_len;
+    char st_buff[5];
+    char *st_str;
+#endif
 } kpathsea_instance;
 
 /* these come from kpathsea.c */
diff --git a/source/texk/kpathsea/variable.c b/source/texk/kpathsea/variable.c
index f2072441ab8b033fbadd4cb8a6ac1d93c71d3826..e19083de110cb0a454e88487f7baf342f8d23358 100644
--- a/source/texk/kpathsea/variable.c
+++ b/source/texk/kpathsea/variable.c
@@ -1,6 +1,6 @@
 /* variable.c: variable expansion.
 
-    Copyright 1993, 1994, 1995, 1996, 2008, 2009, 2011, 2012 Karl Berry.
+    Copyright 1993, 1994, 1995, 1996, 2008, 2009, 2011, 2012, 2016 Karl Berry.
     Copyright 1997, 1999, 2001, 2002, 2005 Olaf Weber.
 
     This library is free software; you can redistribute it and/or
@@ -222,7 +222,7 @@ kpathsea_var_expand (kpathsea kpse, const_string src)
 
         while (*var_end && !IS_VAR_END_DELIMITER (*var_end)) {
 #if defined(WIN32)
-          if (IS_KANJI(var_end))
+          if (kpathsea_IS_KANJI(kpse, var_end))
             var_end++;
 #endif
           var_end++;
diff --git a/source/texk/kpathsea/version.ac b/source/texk/kpathsea/version.ac
index 45e85a60797fa8dd08acb9593f240748e281821e..ad16955afd8b568f0aee494d958b173189f1708e 100644
--- a/source/texk/kpathsea/version.ac
+++ b/source/texk/kpathsea/version.ac
@@ -1,4 +1,4 @@
-dnl $Id: version.ac 39950 2016-03-06 21:56:59Z karl $
+dnl $Id: version.ac 41571 2016-06-29 23:09:13Z karl $
 dnl   Copyright 2016 Karl Berry <tex-live@tug.org>
 dnl   Copyright 2011-2015 Peter Breitenlohner <tex-live@tug.org>
 dnl
@@ -20,4 +20,4 @@ dnl     append "dev", to distinguish binaries built between releases.
 dnl --------------------------------------------------------
 dnl
 dnl  this file is m4-included from configure.ac
-m4_define([kpse_version], [6.2.2])
+m4_define([kpse_version], [6.2.3/dev])
diff --git a/source/texk/kpathsea/win32lib.c b/source/texk/kpathsea/win32lib.c
index 8fa05b9260969607012ffbb81db697605ae846ad..9b4a615c6e2e7b359d858a22180269ea0ebfa6a3 100644
--- a/source/texk/kpathsea/win32lib.c
+++ b/source/texk/kpathsea/win32lib.c
@@ -172,7 +172,7 @@ void texlive_gs_init(void)
                1 if succeeded
 */
 
-int getlongpath(char *buff, char *input, int len)
+int kpathsea_getlongpath(kpathsea kpse, char *buff, char *input, int len)
 {
    HANDLE hnd;
    WIN32_FIND_DATA ffd;
@@ -202,7 +202,7 @@ UNC name
       p += 2;
       r += 2;
       while(*p != '\\' && *p) {
-         if (IS_KANJI(p)) {
+         if (kpathsea_IS_KANJI(kpse, p)) {
             cnt++;
             if(cnt > len) return 0;
             *r++ = *p++;
@@ -216,7 +216,7 @@ UNC name
       *r++ = '/';
       if(*p) p++;
       while(*p != '\\' && *p) {
-         if (IS_KANJI(p)) {
+         if (kpathsea_IS_KANJI(kpse, p)) {
             cnt++;
             if(cnt > len) return 0;
             *r++ = *p++;
@@ -244,7 +244,7 @@ drive name
    }
 
    for( ; *p; p++) {
-      if(IS_KANJI(p)) {
+      if(kpathsea_IS_KANJI(kpse, p)) {
          p++;
          continue;
       }
@@ -292,7 +292,7 @@ file itself
 /* Sync'ed with Emacs 19.34.6 by Marc Paquette <marcpa@cam.org> */
 /* Adapted to fpTeX 0.4 by Fabrice Popineau <Fabrice.Popineau@supelec.fr> */
 
-char * get_home_directory()
+char * kpathsea_get_home_directory(kpathsea kpse)
 {
   char *p;
   char *home = getenv("HOME");
@@ -301,7 +301,7 @@ char * get_home_directory()
   if(home) {
     home = xstrdup(home);
     for(p = home; *p; p++) {
-      if(IS_KANJI(p)) {
+      if(kpathsea_IS_KANJI(kpse, p)) {
         p++;
         continue;
       }
@@ -360,7 +360,7 @@ kpathsea_init_user_info (kpathsea kpse)
 
    /* Ensure HOME and SHELL are defined. */
 
-   home = get_home_directory();
+   home = kpathsea_get_home_directory(kpse);
    if (home) {
       putenv(concat("HOME=", home));
    }
@@ -381,7 +381,7 @@ kpathsea_init_user_info (kpathsea kpse)
    }
 
    /* Set dir and shell from environment variables. */
-   strcpy (kpse->the_passwd.pw_dir, get_home_directory());
+   strcpy (kpse->the_passwd.pw_dir, kpathsea_get_home_directory(kpse));
    strcpy (kpse->the_passwd.pw_shell, getenv ("SHELL"));
 }
 
@@ -424,6 +424,16 @@ int win32_system(const char *cmd)
 }
 
 #if defined (KPSE_COMPAT_API)
+int getlongpath(char *buff, char *input, int len)
+{
+  return kpathsea_getlongpath(kpse_def, buff, input, len);
+}
+
+char * get_home_directory(void)
+{
+  return kpathsea_get_home_directory(kpse_def);
+}
+
 int 
 getuid (void) 
 { 
diff --git a/source/texk/kpathsea/win32lib.h b/source/texk/kpathsea/win32lib.h
index badb32b4e89be431a142da1195ca637e74578af8..005ee92bc6251e4693ddeddf5b2def51ab9a277c 100644
--- a/source/texk/kpathsea/win32lib.h
+++ b/source/texk/kpathsea/win32lib.h
@@ -275,8 +275,13 @@ extern KPSEDLL int pclose(FILE * f);
 extern KPSEDLL int system(const char * cmd);
 
 extern KPSEDLL void texlive_gs_init(void);
+extern KPSEDLL int kpathsea_getlongpath (kpathsea kpse, char *output, char *input, int len);
+extern KPSEDLL char *kpathsea_get_home_directory (kpathsea kpse);
+
+#if defined (KPSE_COMPAT_API)
 extern KPSEDLL int getlongpath (char *output, char *input, int len);
 extern KPSEDLL char *get_home_directory (void);
+#endif
 
 #define off_t __int64
 #define xfseeko xfseek64
diff --git a/source/texk/kpathsea/xbasename.c b/source/texk/kpathsea/xbasename.c
index c66da1cf62242483d93846a10f446a12c215187f..c3f29b7828ed9b52a51b7a79fefd3b7e7076db41 100644
--- a/source/texk/kpathsea/xbasename.c
+++ b/source/texk/kpathsea/xbasename.c
@@ -1,6 +1,6 @@
 /* xbasename.c: return the last element in a path.
 
-   Copyright 1992, 1994, 1995, 1996, 2008, 2011 Karl Berry.
+   Copyright 1992, 1994, 1995, 1996, 2008, 2011, 2016 Karl Berry.
    Copyright 2005 Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -38,13 +38,13 @@ xbasename (const_string name)
         unsigned limit;
 
         for (limit = 2; name[limit] && !IS_DIR_SEP (name[limit]); limit++)
-#if defined(WIN32)
+#if defined(WIN32) && defined (KPSE_COMPAT_API)
             if (IS_KANJI(name+limit)) limit++
 #endif
             ;
         if (name[limit++] && name[limit] && !IS_DIR_SEP (name[limit])) {
             for (; name[limit] && !IS_DIR_SEP (name[limit]); limit++)
-#if defined(WIN32)
+#if defined(WIN32) && defined (KPSE_COMPAT_API)
                 if (IS_KANJI(name+limit)) limit++
 #endif
                 ;
@@ -57,7 +57,7 @@ xbasename (const_string name)
     for (p = base; *p; p++) {
         if (IS_DIR_SEP(*p))
             base = p + 1;
-#if defined(WIN32)
+#if defined(WIN32) && defined (KPSE_COMPAT_API)
         else if (IS_KANJI(p))
             p++;
 #endif
diff --git a/source/texk/kpathsea/xdirname.c b/source/texk/kpathsea/xdirname.c
index c5b38bae8910833b120c3ddcc6316c08238abaa3..0aab9b4b0018f9194574904bbd150d58b518ea2c 100644
--- a/source/texk/kpathsea/xdirname.c
+++ b/source/texk/kpathsea/xdirname.c
@@ -1,6 +1,6 @@
 /* xdirname.c: return the directory part of a path.
 
-   Copyright 1999, 2008, 2011 Karl Berry.
+   Copyright 1999, 2008, 2011, 2016 Karl Berry.
    Copyright 2005 Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -43,13 +43,13 @@ xdirname (const_string name)
         limit = 2;
     } else if (IS_UNC_NAME(name)) {
         for (limit = 2; name[limit] && !IS_DIR_SEP (name[limit]); limit++)
-#if defined(WIN32)
+#if defined(WIN32) && defined(KPSE_COMPAT_API)
             if (IS_KANJI(name+limit)) limit++
 #endif
             ;
         if (name[limit++] && name[limit] && !IS_DIR_SEP (name[limit])) {
             for (; name[limit] && !IS_DIR_SEP (name[limit]); limit++)
-#if defined(WIN32)
+#if defined(WIN32) && defined(KPSE_COMPAT_API)
                 if (IS_KANJI(name+limit)) limit++
 #endif
                 ;
@@ -68,7 +68,10 @@ xdirname (const_string name)
             for (i++; IS_DIR_SEP (name[i]); i++)
                 ;
             loc = i + 1;
-        } else if (IS_KANJI(name+i)) i++;
+        }
+#if defined (KPSE_COMPAT_API)
+        else if (IS_KANJI(name+i)) i++;
+#endif
     }
 #else
     for (loc = strlen (name); loc > limit && !IS_DIR_SEP (name[loc-1]); loc--)
@@ -107,8 +110,10 @@ xdirname (const_string name)
     for (p = ret; *p; p++) {
         if (*p == '\\')
             *p = '/';
+#if defined (KPSE_COMPAT_API)
         else if (IS_KANJI(p))
             p++;
+#endif
     }
 #endif
 
diff --git a/source/texk/kpathsea/xdirtest.c b/source/texk/kpathsea/xdirtest.c
index 9deca79df9e3c1bfa794e162b684596634d18a35..1c657fc15fe30a3132a0add13ee6dceab1367a7c 100644
--- a/source/texk/kpathsea/xdirtest.c
+++ b/source/texk/kpathsea/xdirtest.c
@@ -3,6 +3,7 @@
    Copyright 1999 Karl Berry.
    Copyright 2005 Olaf Weber.
    Copyright 2011 Peter Breitenlohner.
+   Copyright 2016 Akira Kakuto.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -100,10 +101,10 @@ from_kanji (char *str) {
 }
 
 static void
-do_kanji (void) {
+do_kanji (kpathsea kpse) {
     const char **p;
 
-    printf("\nAssuming CP %s 932\n", is_cp932_system ? "is" : "is not");
+    printf("\nAssuming CP %s 932\n", kpse->Is_cp932_system ? "is" : "is not");
 
     for (p = ktab; *p; p++) {
         char *q = to_kanji(*p);
@@ -117,18 +118,18 @@ do_kanji (void) {
 }
 
 static void
-kanji_test(void) {
-    int save_cp932 = is_cp932_system;
+kanji_test(kpathsea kpse) {
+    int save_cp932 = kpse->Is_cp932_system;
 
     printf("\nTesting 2-Byte Kanji (CP 932, SJIS) codes with 'K' representing 0x81\n");
 
-    is_cp932_system = 932;	/* pretend CP is 932 */
-    do_kanji();
+    kpse->Is_cp932_system = 932;	/* pretend CP is 932 */
+    do_kanji(kpse);
 
-    is_cp932_system = 0;	/* pretend CP is not 932 */
-    do_kanji();
+    kpse->Is_cp932_system = 0;	/* pretend CP is not 932 */
+    do_kanji(kpse);
 
-    is_cp932_system = save_cp932;
+    kpse->Is_cp932_system = save_cp932;
 }
 #endif
 
@@ -150,7 +151,7 @@ int main(int argc, char **argv)
     }
 
 #if defined (WIN32)
-    kanji_test();
+    kanji_test(kpse);
 #endif
 
     return 0;
diff --git a/source/texk/kpathsea/xgetcwd.c b/source/texk/kpathsea/xgetcwd.c
index dae50ddb99878102a2b89dde562f3ea626af64c5..b8a95340349f20c3ac3da3c016d690c1d517c59f 100644
--- a/source/texk/kpathsea/xgetcwd.c
+++ b/source/texk/kpathsea/xgetcwd.c
@@ -1,6 +1,6 @@
 /* xgetcwd.c: a from-scratch version of getwd.  Ideas from tcsh 5.20 source.
 
-   Copyright 1992, 1994, 1996, 2008, 2011 Karl Berry.
+   Copyright 1992, 1994, 1996, 2008, 2011, 2016 Karl Berry.
    Copyright 2005 Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -61,8 +61,10 @@ xgetcwd (void)
     for (pp = path; *pp; pp++) {
         if (*pp == '\\')
             *pp = '/';
+#if defined (KPSE_COMPAT_API)
         else if (IS_KANJI(pp))
             pp++;
+#endif
     }
 #endif
 
diff --git a/source/texk/texlive/configure b/source/texk/texlive/configure
index d3f7adebf102852a175ded263a72f4b9672542de..a0a65d99299ac6e38f1a6f8e3932c3f8fbe38b9f 100755
--- a/source/texk/texlive/configure
+++ b/source/texk/texlive/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for TeX Live Scripts 2016.
+# Generated by GNU Autoconf 2.69 for TeX Live Scripts 2017/dev.
 #
 # Report bugs to <tex-k@tug.org>.
 #
@@ -579,8 +579,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='TeX Live Scripts'
 PACKAGE_TARNAME='tex-live-scripts'
-PACKAGE_VERSION='2016'
-PACKAGE_STRING='TeX Live Scripts 2016'
+PACKAGE_VERSION='2017/dev'
+PACKAGE_STRING='TeX Live Scripts 2017/dev'
 PACKAGE_BUGREPORT='tex-k@tug.org'
 PACKAGE_URL=''
 
@@ -1238,7 +1238,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures TeX Live Scripts 2016 to adapt to many kinds of systems.
+\`configure' configures TeX Live Scripts 2017/dev to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1305,7 +1305,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of TeX Live Scripts 2016:";;
+     short | recursive ) echo "Configuration of TeX Live Scripts 2017/dev:";;
    esac
   cat <<\_ACEOF
 
@@ -1400,7 +1400,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-TeX Live Scripts configure 2016
+TeX Live Scripts configure 2017/dev
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1455,7 +1455,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by TeX Live Scripts $as_me 2016, which was
+It was created by TeX Live Scripts $as_me 2017/dev, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2322,7 +2322,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='tex-live-scripts'
- VERSION='2016'
+ VERSION='2017/dev'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -4224,7 +4224,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by TeX Live Scripts $as_me 2016, which was
+This file was extended by TeX Live Scripts $as_me 2017/dev, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -4281,7 +4281,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-TeX Live Scripts config.status 2016
+TeX Live Scripts config.status 2017/dev
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/source/texk/web2c/configure b/source/texk/web2c/configure
index 0cd798a85e53768e6b246b7b573d52d57ec65d8c..7e278b7c096bffd45e789fad599a53e551c30232 100755
--- a/source/texk/web2c/configure
+++ b/source/texk/web2c/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for Web2C 2016.
+# Generated by GNU Autoconf 2.69 for Web2C 2017/dev.
 #
 # Report bugs to <tex-k@tug.org>.
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='Web2C'
 PACKAGE_TARNAME='web2c'
-PACKAGE_VERSION='2016'
-PACKAGE_STRING='Web2C 2016'
+PACKAGE_VERSION='2017/dev'
+PACKAGE_STRING='Web2C 2017/dev'
 PACKAGE_BUGREPORT='tex-k@tug.org'
 PACKAGE_URL=''
 
@@ -1608,7 +1608,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Web2C 2016 to adapt to many kinds of systems.
+\`configure' configures Web2C 2017/dev to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1682,7 +1682,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Web2C 2016:";;
+     short | recursive ) echo "Configuration of Web2C 2017/dev:";;
    esac
   cat <<\_ACEOF
 
@@ -1903,7 +1903,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Web2C configure 2016
+Web2C configure 2017/dev
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2992,7 +2992,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Web2C $as_me 2016, which was
+It was created by Web2C $as_me 2017/dev, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3373,7 +3373,7 @@ ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
 
 
 
-WEB2CVERSION=2016
+WEB2CVERSION=2017/dev
 
 
 am__api_version='1.15'
@@ -8680,7 +8680,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='web2c'
- VERSION='2016'
+ VERSION='2017/dev'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -22501,7 +22501,7 @@ Usage: $0 [OPTIONS]
 Report bugs to <bug-libtool@gnu.org>."
 
 lt_cl_version="\
-Web2C config.lt 2016
+Web2C config.lt 2017/dev
 configured by $0, generated by GNU Autoconf 2.69.
 
 Copyright (C) 2011 Free Software Foundation, Inc.
@@ -25610,7 +25610,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by Web2C $as_me 2016, which was
+This file was extended by Web2C $as_me 2017/dev, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -25680,7 +25680,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-Web2C config.status 2016
+Web2C config.status 2017/dev
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/source/texk/web2c/lib/ChangeLog b/source/texk/web2c/lib/ChangeLog
index 5994ef7ac802c742293a23d3e6f326e5dca55ae0..729d5974740750c5321acb13691a0529a26ec540 100644
--- a/source/texk/web2c/lib/ChangeLog
+++ b/source/texk/web2c/lib/ChangeLog
@@ -1,6 +1,17 @@
+2016-06-12  Karl Berry  <karl@freefriends.org>
+
+	* texmfmp.c (get_date_and_time):
+	rename envvar SOURCE_DATE_EPOCH_TEX_PRIMITIVES to FORCE_SOURCE_DATE.
+	http://tug.org/pipermail/tex-k/2016-June/002722.html
+	(and surrounding thread, starting in May)
+
+2016-05-20  Karl Berry  <karl@tug.org>
+
+	* TeX Live 2016 release.
+
 2016-05-06  Akira Kakuto  <kakuto@fuk.kinidai.ac.jp>
 
-	* texmfmp.c: Avoid to crash for too large a value of SOURCE_DATE_EPOCH.
+	* texmfmp.c: Avoid crash for too large a value of SOURCE_DATE_EPOCH.
 	(w32 only).
 
 2016-05-06  Karl Berry  <karl@tug.org>
diff --git a/source/texk/web2c/lib/texmfmp.c b/source/texk/web2c/lib/texmfmp.c
index cd7953a9301cab98f02f05a0691e5ee170d9c35b..ceb7094de6147ca8fd06f914c9af77162f57137d 100644
--- a/source/texk/web2c/lib/texmfmp.c
+++ b/source/texk/web2c/lib/texmfmp.c
@@ -2247,7 +2247,7 @@ get_date_and_time (integer *minutes,  integer *day,
 {
   struct tm *tmptr;
 #ifndef onlyTeX
-  string sde_texprim = getenv ("SOURCE_DATE_EPOCH_TEX_PRIMITIVES");
+  string sde_texprim = getenv ("FORCE_SOURCE_DATE");
   if (sde_texprim && STREQ (sde_texprim, "1")) {
     init_start_time ();
     tmptr = gmtime (&start_time);
@@ -2263,7 +2263,7 @@ get_date_and_time (integer *minutes,  integer *day,
     /* warn if they gave an invalid value, empty (null string) ok.  */
     if (sde_texprim && strlen (sde_texprim) > 0
         && !STREQ (sde_texprim, "0")) {
-WARNING1 ("invalid value (expected 0 or 1) for environment variable $SOURCE_DATE_EPOCH_TEX_PRIMITIVES: %s", 
+WARNING1 ("invalid value (expected 0 or 1) for environment variable $FORCE_SOURCE_DATE: %s", 
           sde_texprim);
     }
 #endif /* not onlyTeX */
diff --git a/source/texk/web2c/luatexdir/dvi/dvigen.w b/source/texk/web2c/luatexdir/dvi/dvigen.w
index 0a3ca08ea14c95bedc7b18a1da2ed1ec9b108942..d703db1a2a8327fe746bc0ce9da1902d671e23df 100644
--- a/source/texk/web2c/luatexdir/dvi/dvigen.w
+++ b/source/texk/web2c/luatexdir/dvi/dvigen.w
@@ -39,21 +39,6 @@
 
 #define mode cur_list.mode_field        /* current mode */
 
-#define mag int_par(mag_code)
-#define tracing_output int_par(tracing_output_code)
-#define tracing_stats int_par(tracing_stats_code)
-#define tracing_online int_par(tracing_online_code)
-#define page_width dimen_par(page_width_code)
-#define page_height dimen_par(page_height_code)
-#define page_left_offset dimen_par(page_left_offset_code)
-#define page_right_offset dimen_par(page_right_offset_code)
-#define page_top_offset dimen_par(page_top_offset_code)
-#define page_bottom_offset dimen_par(page_bottom_offset_code)
-#define h_offset dimen_par(h_offset_code)
-#define v_offset dimen_par(v_offset_code)
-
-#define count(A) eqtb[count_base+(A)].cint
-
 @ The most important output produced by a run of \TeX\ is the ``device
 independent'' (\.{DVI}) file that specifies where characters and rules
 are to appear on printed pages. The form of these files was designed by
@@ -1136,7 +1121,7 @@ void ensure_dvi_header_written(PDF pdf)
     dvi_four(25400000);
     dvi_four(473628672);        /* conversion ratio for sp */
     prepare_mag();
-    dvi_four(mag);              /* magnification factor is frozen */
+    dvi_four(mag_par);          /* magnification factor is frozen */
     if (output_comment) {
         l = (unsigned) strlen(output_comment);
         dvi_out(l);
@@ -1146,14 +1131,14 @@ void ensure_dvi_header_written(PDF pdf)
         old_setting = selector;
         selector = new_string;
         tprint(" LuaTeX output ");
-        print_int(int_par(year_code));
+        print_int(year_par);
         print_char('.');
-        print_two(int_par(month_code));
+        print_two(month_par);
         print_char('.');
-        print_two(int_par(day_code));
+        print_two(day_par);
         print_char(':');
-        print_two(int_par(time_code) / 60);
-        print_two(int_par(time_code) % 60);
+        print_two(time_par / 60);
+        print_two(time_par % 60);
         selector = old_setting;
         dvi_out(cur_length);
         for (s = 0; s < cur_length; s++)
@@ -1236,7 +1221,7 @@ void finish_dvi_file(PDF pdf, int version, int revision)
         dvi_four(25400000);
         dvi_four(473628672);    /* conversion ratio for sp */
         prepare_mag();
-        dvi_four(mag);          /* magnification factor */
+        dvi_four(mag_par);      /* magnification factor */
         dvi_four(max_v);
         dvi_four(max_h);
         dvi_out(max_push / 256);
diff --git a/source/texk/web2c/luatexdir/font/dofont.w b/source/texk/web2c/luatexdir/font/dofont.w
index db4c2a5ebf064d07fb160447efb93d38598e7ed6..b91bec106898eb60c0a24a04467159c9ce9c3a42 100644
--- a/source/texk/web2c/luatexdir/font/dofont.w
+++ b/source/texk/web2c/luatexdir/font/dofont.w
@@ -81,8 +81,8 @@ static int do_define_font(int f, const char *cnom, scaled s, int natural_dir)
     } else if (callback_id == 0) {
         res = read_tfm_info(f, cnom, s);
         if (res) {
-            set_hyphen_char(f, int_par(default_hyphen_char_code));
-            set_skew_char(f, int_par(default_skew_char_code));
+            set_hyphen_char(f, default_hyphen_char_par);
+            set_skew_char(f, default_skew_char_par);
         }
     }
     if (font_name(f) && strlen(font_name(f)) > 255) {
@@ -120,7 +120,7 @@ int read_font_info(pointer u, char *cnom, scaled s, int natural_dir)
             "e.g., type `I\\font<same font id>=<substitute font name>'.",
             NULL
         };
-        if (int_par(suppress_fontnotfound_error_code) == 0) {
+        if (suppress_fontnotfound_error_par == 0) {
             msg = font_error_message(u, cnom, s);
             tex_error(msg, help);
             free(msg);
diff --git a/source/texk/web2c/luatexdir/font/luafont.w b/source/texk/web2c/luatexdir/font/luafont.w
index daf20e65b7ed566ee95dfa5bdad532e1f911a92b..f3a8e52792c59eca3f58892fbe08ebd5d984ab0a 100644
--- a/source/texk/web2c/luatexdir/font/luafont.w
+++ b/source/texk/web2c/luatexdir/font/luafont.w
@@ -1389,9 +1389,9 @@ int font_from_lua(lua_State * L, int f)
         i = FONT_SLANT_MAX;
     set_font_slant(f, i);
 
-    i = lua_numeric_field_by_index(L,lua_key_index(hyphenchar), int_par(default_hyphen_char_code));
+    i = lua_numeric_field_by_index(L,lua_key_index(hyphenchar), default_hyphen_char_par);
     set_hyphen_char(f, i);
-    i = lua_numeric_field_by_index(L,lua_key_index(skewchar), int_par(default_skew_char_code));
+    i = lua_numeric_field_by_index(L,lua_key_index(skewchar), default_skew_char_par);
     set_skew_char(f, i);
     i = n_boolean_field(L, lua_key_index(used), 0);
     set_font_used(f, (char) i);
@@ -2126,21 +2126,20 @@ halfword handle_kerning(halfword head, halfword tail)
 @c
 static halfword run_lua_ligkern_callback(halfword head, halfword tail, int callback_id)
 {
-    lua_State *L = Luas;
     int i;
-    int top = lua_gettop(L);
-    if (!get_callback(L, callback_id)) {
-        lua_pop(L, 2);
+    int top = lua_gettop(Luas);
+    if (!get_callback(Luas, callback_id)) {
+        lua_pop(Luas, 2);
         return tail;
     }
-    nodelist_to_lua(L, head);
-    nodelist_to_lua(L, tail);
-    if ((i=lua_pcall(L, 2, 0, 0)) != 0) {
-        luatex_error(L, (i == LUA_ERRRUN ? 0 : 1));
+    nodelist_to_lua(Luas, head);
+    nodelist_to_lua(Luas, tail);
+    if ((i=lua_pcall(Luas, 2, 0, 0)) != 0) {
+        luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1));
         return tail;
     }
     fix_node_list(head);
-    lua_settop(L, top);
+    lua_settop(Luas, top);
     return tail;
 }
 
diff --git a/source/texk/web2c/luatexdir/font/mapfile.w b/source/texk/web2c/luatexdir/font/mapfile.w
index 939468af4d89fb20f91957bdb755745afc3ad7a7..f4f31e5a83388c3b28c8433f0d606527b63f68f9 100644
--- a/source/texk/web2c/luatexdir/font/mapfile.w
+++ b/source/texk/web2c/luatexdir/font/mapfile.w
@@ -58,7 +58,7 @@ mapitem *mitem = NULL;
     while (*r != ' ' && *r != '<' && *r != '"' && *r != '\0') \
         *q++ = *r++;                \
     *q = '\0';                      \
-    skip (r, ' ');                  \
+    skip_char(r, ' ');                  \
 } while (0)
 
 #define set_field(F) do {           \
@@ -367,7 +367,7 @@ static void fm_scan_line(void)
         }
     }
     while (1) {                 /* loop through "specials", encoding, font file */
-        skip(r, ' ');
+        skip_char(r, ' ');
         switch (*r) {
         case '\0':
             goto done;
@@ -375,7 +375,7 @@ static void fm_scan_line(void)
             r++;
             u = v = 0;
             do {
-                skip(r, ' ');
+                skip_char(r, ' ');
                 if (sscanf(r, "%f %n", &d, &j) > 0) {
                     s = r + j;  /* jump behind number, eat also blanks, if any */
                     if (*(s - 1) == 'E' || *(s - 1) == 'e')
diff --git a/source/texk/web2c/luatexdir/font/texfont.w b/source/texk/web2c/luatexdir/font/texfont.w
index 06926a2f5a1899734ac52acbbc2d992637bea438..e68deac84ade915bc8524c89b030859fe7447355 100644
--- a/source/texk/web2c/luatexdir/font/texfont.w
+++ b/source/texk/web2c/luatexdir/font/texfont.w
@@ -354,22 +354,21 @@ int char_exists(internal_font_number f, int c)
 static int lua_char_exists_callback(internal_font_number f, int c)
 {
     int callback_id;
-    lua_State *L = Luas;
     int ret = 0;
     callback_id = callback_defined(char_exists_callback);
     if (callback_id != 0) {
-        if (!get_callback(L, callback_id)) {
-            lua_pop(L, 2);
+        if (!get_callback(Luas, callback_id)) {
+            lua_pop(Luas, 2);
             return 0;
         }
-        lua_pushinteger(L, f);
-        lua_pushinteger(L, c);
-        if (lua_pcall(L, 2, 1, 0) != 0) {       /* two args, 1 result */
-            fprintf(stdout, "error: %s\n", lua_tostring(L, -1));
-            lua_pop(L, 2);
+        lua_pushinteger(Luas, f);
+        lua_pushinteger(Luas, c);
+        if (lua_pcall(Luas, 2, 1, 0) != 0) {       /* two args, 1 result */
+            fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1));
+            lua_pop(Luas, 2);
             error();
         } else {
-            ret = lua_toboolean(L, -1);
+            ret = lua_toboolean(Luas, -1);
         }
     }
     return ret;
@@ -1798,8 +1797,6 @@ void undump_font(int f)
 /* moved from pdffont.w */
 
 @ @c
-#define font_id_text(A) cs_text(font_id_base+(A)) /* a frozen font identifier's name */
-
 int pk_dpi; /* PK pixel density value from \.{texmf.cnf} */
 
 @ @c
diff --git a/source/texk/web2c/luatexdir/font/writet1.w b/source/texk/web2c/luatexdir/font/writet1.w
index 958adfbb0dbdb8b29fa07bd4ab3e7d86bc133337..fc1a89cd547eea8ff470371012009deabf09ac79 100644
--- a/source/texk/web2c/luatexdir/font/writet1.w
+++ b/source/texk/web2c/luatexdir/font/writet1.w
@@ -309,13 +309,13 @@ char **load_enc_file(char *enc_name)
     }
     names_count = 0;
     r++;                        /* skip '[' */
-    skip(r, ' ');
+    skip_char(r, ' ');
     for (;;) {
         while (*r == '/') {
             for (p = buf, r++;
                  *r != ' ' && *r != 10 && *r != ']' && *r != '/'; *p++ = *r++);
             *p = 0;
-            skip(r, ' ');
+            skip_char(r, ' ');
             if (names_count >= 256)
                 normal_error("type 1","encoding vector contains more than 256 names");
             if (strcmp(buf, notdef) != 0)
@@ -444,7 +444,7 @@ static char *eol(char *s)
 static float t1_scan_num(char *p, char **r)
 {
     float f;
-    skip(p, ' ');
+    skip_char(p, ' ');
     if (sscanf(p, "%g", &f) != 1) {
         remove_eol(p, t1_line_array);
         formatted_error("type 1","a number expected: '%s'", t1_line_array);
@@ -682,7 +682,7 @@ static void t1_scan_keys(PDF pdf)
     if (key - font_key == FONT_KEYS_NUM)
         return;
     p = t1_line_array + strlen(key->t1name) + 1;
-    skip(p, ' ');
+    skip_char(p, ' ');
     if ((k = (int) (key - font_key)) == FONTNAME_CODE) {
         if (*p != '/') {
             remove_eol(p, t1_line_array);
@@ -787,14 +787,14 @@ static char **t1_builtin_enc(void)
     t1_encoding = ENC_BUILTIN;
     if (t1_prefix("/Encoding [") || t1_prefix("/Encoding[")) {  /* the first case */
         r = strchr(t1_line_array, '[') + 1;
-        skip(r, ' ');
+        skip_char(r, ' ');
         for (;;) {
             while (*r == '/') {
                 for (p = t1_buf_array, r++;
                      *r != 32 && *r != 10 && *r != ']' && *r != '/';
                      *p++ = *r++);
                 *p = 0;
-                skip(r, ' ');
+                skip_char(r, ' ');
                 if (counter > 255)
                     normal_error("type 1","encoding vector contains more than 256 names");
                 if (strcmp(t1_buf_array, notdef) != 0)
@@ -827,7 +827,7 @@ static char **t1_builtin_enc(void)
                 if (strcmp(t1_buf_array + 1, notdef) != 0)
                     glyph_names[i] = xstrdup(t1_buf_array + 1);
                 p = strstr(p, " put") + strlen(" put");
-                skip(p, ' ');
+                skip_char(p, ' ');
             }
             /*
                check for \.{dup dup <to> exch <from> get put}
@@ -836,7 +836,7 @@ static char **t1_builtin_enc(void)
                      && valid_code(a) && valid_code(b)) {
                 copy_glyph_names(glyph_names, a, b);
                 p = strstr(p, " get put") + strlen(" get put");
-                skip(p, ' ');
+                skip_char(p, ' ');
             }
             /*
                check for \.{dup dup <from> <size> getinterval <to> exch putinterval}
@@ -848,7 +848,7 @@ static char **t1_builtin_enc(void)
                 for (i = 0; i < c; i++)
                     copy_glyph_names(glyph_names, a + i, b + i);
                 p = strstr(p, " putinterval") + strlen(" putinterval");
-                skip(p, ' ');
+                skip_char(p, ' ');
             }
             /*
                check for \.{def} or \.{readonly def}
@@ -862,7 +862,7 @@ static char **t1_builtin_enc(void)
             else {
                 while (*p != ' ' && *p != 10)
                     p++;
-                skip(p, ' ');
+                skip_char(p, ' ');
             }
         }
     }
diff --git a/source/texk/web2c/luatexdir/image/writeimg.w b/source/texk/web2c/luatexdir/image/writeimg.w
index 96a5137d724f8c080529216264292b2ecb2217e0..0944509c044495ab21240f6e51f6ea55d353b717 100644
--- a/source/texk/web2c/luatexdir/image/writeimg.w
+++ b/source/texk/web2c/luatexdir/image/writeimg.w
@@ -427,8 +427,6 @@ void scan_pdfximage(PDF pdf) /* static_pdf */
 }
 
 @ @c
-#define tail cur_list.tail_field
-
 void scan_pdfrefximage(PDF pdf)
 {
     int transform = 0;          /* one could scan transform as well */
@@ -441,20 +439,20 @@ void scan_pdfrefximage(PDF pdf)
     idict = idict_array[obj_data_ptr(pdf, cur_val)];
     if (img_state(idict) == DICT_NEW) {
         normal_warning("image","don't rely on the image data to be okay");
-        width(tail) = 0;
-        height(tail) = 0;
-        depth(tail) = 0;
+        width(tail_par) = 0;
+        height(tail_par) = 0;
+        depth(tail_par) = 0;
     } else {
         if (alt_rule.wd != null_flag || alt_rule.ht != null_flag || alt_rule.dp != null_flag) {
             dim = scale_img(idict, alt_rule, transform);
         } else {
             dim = scale_img(idict, img_dimen(idict), img_transform(idict));
         }
-        width(tail) = dim.wd;
-        height(tail) = dim.ht;
-        depth(tail) = dim.dp;
-        rule_transform(tail) = transform;
-        rule_index(tail) = img_index(idict);
+        width(tail_par) = dim.wd;
+        height(tail_par) = dim.ht;
+        depth(tail_par) = dim.dp;
+        rule_transform(tail_par) = transform;
+        rule_index(tail_par) = img_index(idict);
     }
 }
 
diff --git a/source/texk/web2c/luatexdir/lang/texlang.h b/source/texk/web2c/luatexdir/lang/texlang.h
index 0920dc9f740ae761f9a1c56b5b84de856e3975c8..5e7a046195f2c092253b36bcd0d43a6a1de1c31e 100644
--- a/source/texk/web2c/luatexdir/lang/texlang.h
+++ b/source/texk/web2c/luatexdir/lang/texlang.h
@@ -17,7 +17,6 @@
    You should have received a copy of the GNU General Public License along
    with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
 
-
 #ifndef TEXLANG_H
 #  define TEXLANG_H
 
@@ -46,8 +45,7 @@ struct tex_language {
 extern struct tex_language *new_language(int n);
 extern struct tex_language *get_language(int n);
 extern void load_patterns(struct tex_language *lang, const unsigned char *buf);
-extern void load_hyphenation(struct tex_language *lang,
-                             const unsigned char *buf);
+extern void load_hyphenation(struct tex_language *lang, const unsigned char *buf);
 extern int hyphenate_string(struct tex_language *lang, char *w, char **ret);
 
 extern void new_hyphenation(halfword h, halfword t);
diff --git a/source/texk/web2c/luatexdir/lang/texlang.w b/source/texk/web2c/luatexdir/lang/texlang.w
index c1d67fb0bef50a50e054b1aeafae96acea421976..f89ca5d4a3361347f329d64032180c7cd6ace8c1 100644
--- a/source/texk/web2c/luatexdir/lang/texlang.w
+++ b/source/texk/web2c/luatexdir/lang/texlang.w
@@ -30,8 +30,6 @@
 
 #define MAX_TEX_LANGUAGES  16384
 
-#define ex_hyphen_char int_par(ex_hyphen_char_code)
-
 static struct tex_language *tex_languages[MAX_TEX_LANGUAGES] = { NULL };
 
 static int next_lang_id = 0;
@@ -61,7 +59,7 @@ struct tex_language *new_language(int n)
         lang->pre_exhyphen_char = 0;
         lang->post_exhyphen_char = 0;
         lang->hyphenation_min = -1;
-        if (int_par(saving_hyph_codes_code)) {
+        if (saving_hyph_codes_par) {
             hj_codes_from_lc_codes(l); /* for now, we might just use specific value for whatever task */
         }
         return lang;
@@ -276,14 +274,13 @@ void load_hyphenation(struct tex_language *lang, const unsigned char *buff)
     const char *value;
     char *cleaned;
     int id ;
-    lua_State *L = Luas;
     if (lang == NULL)
         return;
     if (lang->exceptions == 0) {
-        lua_newtable(L);
-        lang->exceptions = luaL_ref(L, LUA_REGISTRYINDEX);
+        lua_newtable(Luas);
+        lang->exceptions = luaL_ref(Luas, LUA_REGISTRYINDEX);
     }
-    lua_rawgeti(L, LUA_REGISTRYINDEX, lang->exceptions);
+    lua_rawgeti(Luas, LUA_REGISTRYINDEX, lang->exceptions);
     s = (const char *) buff;
     id = lang->id;
     while (*s) {
@@ -294,9 +291,9 @@ void load_hyphenation(struct tex_language *lang, const unsigned char *buff)
             s = clean_hyphenation(id, s, &cleaned);
             if (cleaned != NULL) {
                 if ((s - value) > 0) {
-                    lua_pushstring(L, cleaned);
-                    lua_pushlstring(L, value, (size_t) (s - value));
-                    lua_rawset(L, -3);
+                    lua_pushstring(Luas, cleaned);
+                    lua_pushlstring(Luas, value, (size_t) (s - value));
+                    lua_rawset(Luas, -3);
                 }
                 free(cleaned);
             } else {
@@ -381,7 +378,7 @@ halfword insert_syllable_discretionary(halfword t, lang_variables * lan)
 {
     halfword g, n;
     n = new_node(disc_node, syllable_disc);
-    disc_penalty(n) = int_par(hyphen_penalty_code);
+    disc_penalty(n) = hyphen_penalty_par;
     couple_nodes(n, vlink(t));
     couple_nodes(t, n);
     delete_attribute_ref(node_attr(n));
@@ -427,7 +424,7 @@ halfword insert_word_discretionary(halfword t, lang_variables * lan)
         pre = insert_character(null, lan->pre_exhyphen_char);
     if (lan->post_exhyphen_char > 0)
         pos = insert_character(null, lan->post_exhyphen_char);
-    return insert_discretionary(t, pre, pos, null,int_par(ex_hyphen_penalty_code));
+    return insert_discretionary(t, pre, pos, null,ex_hyphen_penalty_par);
 }
 
 @ @c
@@ -446,7 +443,7 @@ halfword insert_complex_discretionary(halfword t, lang_variables * lan,
                                       halfword replace)
 {
     (void) lan;
-    return insert_discretionary(t, pre, pos, replace,int_par(hyphen_penalty_code));
+    return insert_discretionary(t, pre, pos, replace,hyphen_penalty_par);
 }
 
 halfword insert_character(halfword t, int c)
@@ -477,18 +474,17 @@ void set_disc_field(halfword f, halfword t)
 static char *hyphenation_exception(int exceptions, char *w)
 {
     char *ret = NULL;
-    lua_State *L = Luas;
-    lua_checkstack(L, 2);
-    lua_rawgeti(L, LUA_REGISTRYINDEX, exceptions);
-    if (lua_istable(L, -1)) {   /* ?? */
-        lua_pushstring(L, w);   /* word table */
-        lua_rawget(L, -2);
-        if (lua_type(L, -1) == LUA_TSTRING) {
-            ret = xstrdup(lua_tostring(L, -1));
+    lua_checkstack(Luas, 2);
+    lua_rawgeti(Luas, LUA_REGISTRYINDEX, exceptions);
+    if (lua_istable(Luas, -1)) {   /* ?? */
+        lua_pushstring(Luas, w);   /* word table */
+        lua_rawget(Luas, -2);
+        if (lua_type(Luas, -1) == LUA_TSTRING) {
+            ret = xstrdup(lua_tostring(Luas, -1));
         }
-        lua_pop(L, 2);
+        lua_pop(Luas, 2);
     } else {
-        lua_pop(L, 1);
+        lua_pop(Luas, 1);
     }
     return ret;
 }
@@ -500,16 +496,15 @@ char *exception_strings(struct tex_language *lang)
     size_t size = 0, current = 0;
     size_t l = 0;
     char *ret = NULL;
-    lua_State *L = Luas;
     if (lang->exceptions == 0)
         return NULL;
-    lua_checkstack(L, 2);
-    lua_rawgeti(L, LUA_REGISTRYINDEX, lang->exceptions);
-    if (lua_istable(L, -1)) {
+    lua_checkstack(Luas, 2);
+    lua_rawgeti(Luas, LUA_REGISTRYINDEX, lang->exceptions);
+    if (lua_istable(Luas, -1)) {
         /* iterate and join */
-        lua_pushnil(L);         /* first key */
-        while (lua_next(L, -2) != 0) {
-            value = lua_tolstring(L, -1, &l);
+        lua_pushnil(Luas);         /* first key */
+        while (lua_next(Luas, -2) != 0) {
+            value = lua_tolstring(Luas, -1, &l);
             if (current + 2 + l > size) {
                 ret = xrealloc(ret, (unsigned) ((size + size / 5) + current + l + 1024));
                 size = (size + size / 5) + current + l + 1024;
@@ -517,7 +512,7 @@ char *exception_strings(struct tex_language *lang)
             *(ret + current) = ' ';
             strcpy(ret + current + 1, value);
             current += l + 1;
-            lua_pop(L, 1);
+            lua_pop(Luas, 1);
         }
     }
     return ret;
@@ -629,7 +624,7 @@ static void do_exception(halfword wordstart, halfword r, char *replacement)
                 try_couple_nodes(t, vlink(q));
                 vlink(q) = null;
             }
-            t = insert_discretionary(t, gg, hh, replace,int_par(hyphen_penalty_code));
+            t = insert_discretionary(t, gg, hh, replace, hyphen_penalty_par);
             t = vlink(t);       /* skip the new disc */
         } else {
             t = vlink(t);
@@ -722,9 +717,7 @@ there was not the best idea ever.
 
 */
 
-static int more_strict = 0 ;
-
-static halfword find_next_wordstart(halfword r, halfword first_language)
+static halfword find_next_wordstart(halfword r, halfword first_language, halfword strict_bound)
 {
     register int l;
     register int start_ok = 1;
@@ -741,8 +734,9 @@ static halfword find_next_wordstart(halfword r, halfword first_language)
         case hlist_node: /* new > 0.95 */
         case vlist_node: /* new > 0.95 */
         case rule_node:  /* new > 0.95 */
+        case dir_node:
         case whatsit_node:
-            if (more_strict == 1 || more_strict == 3) {
+            if (strict_bound == 1 || strict_bound == 3) {
                 start_ok = 0;
             }
             break;
@@ -766,7 +760,7 @@ static halfword find_next_wordstart(halfword r, halfword first_language)
         case glyph_node:
             if (is_simple_character(r)) {
                 chr = character(r) ;
-                if (chr == ex_hyphen_char) {
+                if (chr == ex_hyphen_char_par) {
                     /*
                         We only accept an explicit hyphen when there is a preceding glyph and
                         we skip a sequence of explicit hyphens as that normally indicates a
@@ -776,7 +770,7 @@ static halfword find_next_wordstart(halfword r, halfword first_language)
                         hyphenation, ligaturing and kerning steps. A test is cmr with ------.
                     */
                     t = vlink(r) ;
-                    if ((start_ok == 0) && (t!=null) && (type(t) == glyph_node) && (character(t) != ex_hyphen_char)) {
+                    if ((start_ok == 0) && (t!=null) && (type(t) == glyph_node) && (character(t) != ex_hyphen_char_par)) {
                         t = compound_word_break(r, char_lang(r));
                         subtype(t) = automatic_disc;
                         start_ok = 1 ;
@@ -802,7 +796,7 @@ static halfword find_next_wordstart(halfword r, halfword first_language)
 }
 
 @ @c
-static int valid_wordend(halfword s)
+static int valid_wordend(halfword s, halfword strict_bound)
 {
     register halfword r = s;
     register int clang = char_lang(s);
@@ -824,10 +818,11 @@ static int valid_wordend(halfword s)
                   ||  ((type(r) == hlist_node   || /* new > 0.95 */
                         type(r) == vlist_node   || /* new > 0.95 */
                         type(r) == rule_node    || /* new > 0.95 */
+                        type(r) == dir_node     || /* new > 0.97 */
                         type(r) == whatsit_node ||
                         type(r) == ins_node     || /* yes or no strict test */
                         type(r) == adjust_node     /* yes or no strict test */
-                       ) && ! (more_strict == 2 || more_strict == 3))
+                       ) && ! (strict_bound == 2 || strict_bound == 3))
                   ||  type(r) == boundary_node
         )
         return 1;
@@ -845,7 +840,8 @@ void hnj_hyphenation(halfword head, halfword tail)
     char *hy = utf8word;
     char *replacement = NULL;
     boolean explicit_hyphen = false;
-    halfword first_language = int_par(first_valid_language_code);
+    halfword first_language = first_valid_language_par;
+    halfword strict_bound = hyphenation_bounds_par;
     halfword s, r = head, wordstart = null, save_tail1 = null, left = null, right = null;
 
     /* this first movement assures two things:
@@ -860,7 +856,7 @@ void hnj_hyphenation(halfword head, halfword tail)
         r = vlink(r);
     }
     /* this will make |r| a glyph node with subtype character */
-    r = find_next_wordstart(r,first_language);
+    r = find_next_wordstart(r,first_language,strict_bound);
     if (r == null)
         return;
 
@@ -891,12 +887,12 @@ void hnj_hyphenation(halfword head, halfword tail)
                 && (    (     (clang >= first_language)
                            && (lchar = get_hj_code(clang,character(r))) > 0
                         )
-                     || (     character(r) == ex_hyphen_char
-                           && (lchar = ex_hyphen_char)
+                     || (     character(r) == ex_hyphen_char_par
+                           && (lchar = ex_hyphen_char_par)
                         )
                    )
               ) {
-            if (character(r) == ex_hyphen_char) {
+            if (character(r) == ex_hyphen_char_par) {
                 explicit_hyphen = true;
             }
             wordlen++;
@@ -919,7 +915,7 @@ void hnj_hyphenation(halfword head, halfword tail)
             end_word = r;
             r = vlink(r);
         }
-        if (     valid_wordend(r)
+        if (     valid_wordend(r,strict_bound)
               && clang >= first_language
               && wordlen >= lhmin + rhmin
               && (hmin <= 0 || wordlen >= hmin)
@@ -947,10 +943,10 @@ void hnj_hyphenation(halfword head, halfword tail)
 #endif
                 while (rr != wordstart) {
                 if (is_simple_character(rr)) {
-                        if (character(rr) == ex_hyphen_char) {
+                        if (character(rr) == ex_hyphen_char_par) {
                             t = compound_word_break(rr, clang);
                             subtype(t) = automatic_disc;
-                            while (character(alink(rr)) == ex_hyphen_char)
+                            while (character(alink(rr)) == ex_hyphen_char_par)
                                 rr = alink(rr);
                             if (rr == wordstart)
                                 break;
@@ -983,7 +979,7 @@ void hnj_hyphenation(halfword head, halfword tail)
         hy = utf8word;
         if (r == null)
             break;
-        r = find_next_wordstart(r,first_language);
+        r = find_next_wordstart(r,first_language,strict_bound);
     }
     flush_node(vlink(tail));
     vlink(tail) = save_tail1;
@@ -998,20 +994,19 @@ void new_hyphenation(halfword head, halfword tail)
     fix_node_list(head);
     callback_id = callback_defined(hyphenate_callback);
     if (callback_id > 0) {
-        lua_State *L = Luas;
-        if (!get_callback(L, callback_id)) {
-            lua_pop(L, 2);
+        if (!get_callback(Luas, callback_id)) {
+            lua_pop(Luas, 2);
             return;
         }
-        nodelist_to_lua(L, head);
-        nodelist_to_lua(L, tail);
-        if (lua_pcall(L, 2, 0, 0) != 0) {
-            formatted_warning("hyphenation","bad specification: %s",lua_tostring(L, -1));
-            lua_pop(L, 2);
-            lua_error(L);
+        nodelist_to_lua(Luas, head);
+        nodelist_to_lua(Luas, tail);
+        if (lua_pcall(Luas, 2, 0, 0) != 0) {
+            formatted_warning("hyphenation","bad specification: %s",lua_tostring(Luas, -1));
+            lua_pop(Luas, 2);
+            lua_error(Luas);
             return;
         }
-        lua_pop(L, 1);
+        lua_pop(Luas, 1);
     } else if (callback_id == 0) {
         hnj_hyphenation(head, tail);
     }
@@ -1126,7 +1121,7 @@ void undump_language_data(void)
 void new_hyph_exceptions(void)
 {                               /* enters new exceptions */
     (void) scan_toks(false, true);
-    load_tex_hyphenation(int_par(language_code), def_ref);
+    load_tex_hyphenation(language_par, def_ref);
     flush_list(def_ref);
 }
 
@@ -1137,7 +1132,7 @@ procedure named |new_patterns|.
 void new_patterns(void)
 {                               /* initializes the hyphenation pattern data */
     (void) scan_toks(false, true);
-    load_tex_patterns(int_par(language_code), def_ref);
+    load_tex_patterns(language_par, def_ref);
     flush_list(def_ref);
 }
 
@@ -1150,14 +1145,14 @@ void new_pre_hyphen_char(void)
 {
     scan_optional_equals();
     scan_int();
-    set_pre_hyphen_char(int_par(language_code), cur_val);
+    set_pre_hyphen_char(language_par, cur_val);
 }
 
 void new_post_hyphen_char(void)
 {
     scan_optional_equals();
     scan_int();
-    set_post_hyphen_char(int_par(language_code), cur_val);
+    set_post_hyphen_char(language_par, cur_val);
 }
 
 @ `\.{\\preexhyphenchar}', sets the |pre_break| character, and
@@ -1169,21 +1164,21 @@ void new_pre_exhyphen_char(void)
 {
     scan_optional_equals();
     scan_int();
-    set_pre_exhyphen_char(int_par(language_code), cur_val);
+    set_pre_exhyphen_char(language_par, cur_val);
 }
 
 void new_post_exhyphen_char(void)
 {
     scan_optional_equals();
     scan_int();
-    set_post_exhyphen_char(int_par(language_code), cur_val);
+    set_post_exhyphen_char(language_par, cur_val);
 }
 
 void new_hyphenation_min(void)
 {
     scan_optional_equals();
     scan_int();
-    set_hyphenation_min(int_par(language_code), cur_val);
+    set_hyphenation_min(language_par, cur_val);
 }
 
 void new_hj_code(void)
@@ -1193,5 +1188,5 @@ void new_hj_code(void)
     i = cur_val;
     scan_optional_equals();
     scan_int();
-    set_hj_code(int_par(language_code), i, cur_val, -1);
+    set_hj_code(language_par, i, cur_val, -1);
 }
diff --git a/source/texk/web2c/luatexdir/lua/lcallbacklib.c b/source/texk/web2c/luatexdir/lua/lcallbacklib.c
index 778fbf188766a354d2e1dbd60aab064be833b39e..5ceb7998d1ddb81c6e3d45a5e69dabe2dc5be76e 100644
--- a/source/texk/web2c/luatexdir/lua/lcallbacklib.c
+++ b/source/texk/web2c/luatexdir/lua/lcallbacklib.c
@@ -196,20 +196,19 @@ int run_saved_callback(int r, const char *name, const char *values, ...)
 {
     va_list args;
     int ret = 0;
-    lua_State *L = Luas;
-    int stacktop = lua_gettop(L);
+    int stacktop = lua_gettop(Luas);
     va_start(args, values);
-    luaL_checkstack(L, 2, "out of stack space");
-    lua_rawgeti(L, LUA_REGISTRYINDEX, r);
-    lua_pushstring(L, name);
-    lua_rawget(L, -2);
-    if (lua_isfunction(L, -1)) {
+    luaL_checkstack(Luas, 2, "out of stack space");
+    lua_rawgeti(Luas, LUA_REGISTRYINDEX, r);
+    lua_pushstring(Luas, name);
+    lua_rawget(Luas, -2);
+    if (lua_isfunction(Luas, -1)) {
         saved_callback_count++;
         callback_count++;
         ret = do_run_callback(2, values, args);
     }
     va_end(args);
-    lua_settop(L, stacktop);
+    lua_settop(Luas, stacktop);
     return ret;
 }
 
@@ -230,17 +229,16 @@ int run_and_save_callback(int i, const char *values, ...)
 {
     va_list args;
     int ret = 0;
-    lua_State *L = Luas;
-    int stacktop = lua_gettop(L);
+    int stacktop = lua_gettop(Luas);
     va_start(args, values);
-    if (get_callback(L, i)) {
+    if (get_callback(Luas, i)) {
         ret = do_run_callback(1, values, args);
     }
     va_end(args);
     if (ret > 0) {
-        ret = luaL_ref(L, LUA_REGISTRYINDEX);
+        ret = luaL_ref(Luas, LUA_REGISTRYINDEX);
     }
-    lua_settop(L, stacktop);
+    lua_settop(Luas, stacktop);
     return ret;
 }
 
@@ -248,14 +246,13 @@ int run_callback(int i, const char *values, ...)
 {
     va_list args;
     int ret = 0;
-    lua_State *L = Luas;
-    int stacktop = lua_gettop(L);
+    int stacktop = lua_gettop(Luas);
     va_start(args, values);
-    if (get_callback(L, i)) {
+    if (get_callback(Luas, i)) {
         ret = do_run_callback(0, values, args);
     }
     va_end(args);
-    lua_settop(L, stacktop);
+    lua_settop(Luas, stacktop);
     return ret;
 }
 
@@ -270,46 +267,45 @@ int do_run_callback(int special, const char *values, va_list vl)
     int *bufloc;
     char *ss = NULL;
     int retval = 0;
-    lua_State *L = Luas;
     if (special == 2) {         /* copy the enclosing table */
-        luaL_checkstack(L, 1, "out of stack space");
-        lua_pushvalue(L, -2);
+        luaL_checkstack(Luas, 1, "out of stack space");
+        lua_pushvalue(Luas, -2);
     }
     ss = strchr(values, '>');
-    luaL_checkstack(L, (int) (ss - values + 1), "out of stack space");
+    luaL_checkstack(Luas, (int) (ss - values + 1), "out of stack space");
     ss = NULL;
     for (narg = 0; *values; narg++) {
         switch (*values++) {
             case CALLBACK_CHARNUM: /* an ascii char! */
                 cs = (char) va_arg(vl, int);
-                lua_pushlstring(L, &cs, 1);
+                lua_pushlstring(Luas, &cs, 1);
                 break;
             case CALLBACK_STRING:  /* C string */
                 s = va_arg(vl, char *);
-                lua_pushstring(L, s);
+                lua_pushstring(Luas, s);
                 break;
             case CALLBACK_LSTRING:  /* 'lstring' */
                 lstr = va_arg(vl, lstring *);
-                lua_pushlstring(L, (const char *)lstr->s, lstr->l);
+                lua_pushlstring(Luas, (const char *)lstr->s, lstr->l);
                 break;
             case CALLBACK_INTEGER: /* int */
-                lua_pushinteger(L, va_arg(vl, int));
+                lua_pushinteger(Luas, va_arg(vl, int));
                 break;
             case CALLBACK_STRNUMBER:       /* TeX string */
                 s = makeclstring(va_arg(vl, int), &len);
-                lua_pushlstring(L, s, len);
+                lua_pushlstring(Luas, s, len);
                 break;
             case CALLBACK_BOOLEAN: /* boolean */
-                lua_pushboolean(L, va_arg(vl, int));
+                lua_pushboolean(Luas, va_arg(vl, int));
                 break;
             case CALLBACK_LINE:    /* a buffer section, with implied start */
-                lua_pushlstring(L, (char *) (buffer + first), (size_t) va_arg(vl, int));
+                lua_pushlstring(Luas, (char *) (buffer + first), (size_t) va_arg(vl, int));
                 break;
             case CALLBACK_NODE:
-                lua_nodelib_push_fast(L,va_arg(vl, int));
+                lua_nodelib_push_fast(Luas, va_arg(vl, int));
                 break;
             case CALLBACK_DIR:
-                lua_push_dir_par(L,va_arg(vl, int));
+                lua_push_dir_par(Luas, va_arg(vl, int));
                 break;
             case '-':
                 narg--;
@@ -331,7 +327,7 @@ int do_run_callback(int special, const char *values, va_list vl)
     {
         int i;
         lua_active++;
-        i = lua_pcall(L, narg, nres, 0);
+        i = lua_pcall(Luas, narg, nres, 0);
         lua_active--;
         /* lua_remove(L, base); *//* remove traceback function */
         if (i != 0) {
@@ -339,11 +335,11 @@ int do_run_callback(int special, const char *values, va_list vl)
              * TeX initialization is complete
              */
             if (!log_opened_global) {
-                fprintf(stderr, "error in callback: %s\n", lua_tostring(L, -1));
+                fprintf(stderr, "error in callback: %s\n", lua_tostring(Luas, -1));
                 error();
             } else {
-                lua_gc(L, LUA_GCCOLLECT, 0);
-                luatex_error(L, (i == LUA_ERRRUN ? 0 : 1));
+                lua_gc(Luas, LUA_GCCOLLECT, 0);
+                luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1));
             }
             return 0;
         }
@@ -355,25 +351,25 @@ int do_run_callback(int special, const char *values, va_list vl)
     while (*values) {
         int b, t;
         halfword p;
-        t = lua_type(L, nres);
+        t = lua_type(Luas, nres);
         switch (*values++) {
             case CALLBACK_BOOLEAN:
                 if (t == LUA_TNIL) {
                     b = 0;
                 } else if (t != LUA_TBOOLEAN) {
-                    fprintf(stderr, "callback should return a boolean, not: %s\n", lua_typename(L, t));
+                    fprintf(stderr, "callback should return a boolean, not: %s\n", lua_typename(Luas, t));
                     goto EXIT;
                 } else {
-                    b = lua_toboolean(L, nres);
+                    b = lua_toboolean(Luas, nres);
                 }
                 *va_arg(vl, boolean *) = (boolean) b;
                 break;
             case CALLBACK_INTEGER:
                 if (t != LUA_TNUMBER) {
-                    fprintf(stderr, "callback should return a number, not: %s\n", lua_typename(L, t));
+                    fprintf(stderr, "callback should return a number, not: %s\n", lua_typename(Luas, t));
                     goto EXIT;
                 }
-                b = lua_tointeger(L, nres);
+                b = lua_tointeger(Luas, nres);
                 *va_arg(vl, int *) = b;
                 break;
             case CALLBACK_LINE:    /* TeX line ... happens frequently when we have a plug-in */
@@ -381,7 +377,7 @@ int do_run_callback(int special, const char *values, va_list vl)
                     bufloc = 0;
                     goto EXIT;
                 } else if (t == LUA_TSTRING) {
-                    s = lua_tolstring(L, nres, &len);
+                    s = lua_tolstring(Luas, nres, &len);
                     if (s == NULL) {    /* |len| can be zero */
                         bufloc = 0;
                     } else if (len == 0) {
@@ -397,16 +393,16 @@ int do_run_callback(int special, const char *values, va_list vl)
                             (*bufloc)--;
                     }
                 } else {
-                    fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(L, t));
+                    fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(Luas, t));
                     goto EXIT;
                 }
                 break;
             case CALLBACK_STRNUMBER:       /* TeX string */
                 if (t != LUA_TSTRING) {
-                    fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(L, t));
+                    fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(Luas, t));
                     goto EXIT;
                 }
-                s = lua_tolstring(L, nres, &len);
+                s = lua_tolstring(Luas, nres, &len);
                 if (s == NULL)      /* |len| can be zero */
                     *va_arg(vl, int *) = 0;
                 else {
@@ -415,10 +411,10 @@ int do_run_callback(int special, const char *values, va_list vl)
                 break;
             case CALLBACK_STRING:  /* C string aka buffer */
                 if (t != LUA_TSTRING) {
-                    fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(L, t));
+                    fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(Luas, t));
                     goto EXIT;
                 }
-                s = lua_tolstring(L, nres, &len);
+                s = lua_tolstring(Luas, nres, &len);
                 if (s == NULL)      /* |len| can be zero */
                     *va_arg(vl, int *) = 0;
                 else {
@@ -431,18 +427,18 @@ int do_run_callback(int special, const char *values, va_list vl)
                 if (t == LUA_TNIL) {
                     *va_arg(vl, int *) = 0;
                 } else if (t == LUA_TBOOLEAN) {
-                    b = lua_toboolean(L, nres);
+                    b = lua_toboolean(Luas, nres);
                     if (b == 0) {
                         *va_arg(vl, int *) = 0;
                     } else {
-                        fprintf(stderr, "callback should return a string, false or nil, not: %s\n", lua_typename(L, t));
+                        fprintf(stderr, "callback should return a string, false or nil, not: %s\n", lua_typename(Luas, t));
                         goto EXIT;
                     }
                 } else if (t != LUA_TSTRING) {
-                    fprintf(stderr, "callback should return a string, false or nil, not: %s\n", lua_typename(L, t));
+                    fprintf(stderr, "callback should return a string, false or nil, not: %s\n", lua_typename(Luas, t));
                     goto EXIT;
                 } else {
-                    s = lua_tolstring(L, nres, &len);
+                    s = lua_tolstring(Luas, nres, &len);
                     if (s == NULL)      /* |len| can be zero */
                         *va_arg(vl, int *) = 0;
                     else {
@@ -454,10 +450,10 @@ int do_run_callback(int special, const char *values, va_list vl)
                 break;
             case CALLBACK_LSTRING:  /* lstring */
                 if (t != LUA_TSTRING) {
-                    fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(L, t));
+                    fprintf(stderr, "callback should return a string, not: %s\n", lua_typename(Luas, t));
                     goto EXIT;
                 }
-                s = lua_tolstring(L, nres, &len);
+                s = lua_tolstring(Luas, nres, &len);
                 if (s == NULL)      /* |len| can be zero */
                     *va_arg(vl, int *) = 0;
                 else {
@@ -472,7 +468,7 @@ int do_run_callback(int special, const char *values, va_list vl)
                 if (t == LUA_TNIL) {
                     p = null;
                 } else {
-                    p = *check_isnode(L,nres);
+                    p = *check_isnode(Luas,nres);
                 }
                 *va_arg(vl, int *) = p;
                 break;
diff --git a/source/texk/web2c/luatexdir/lua/limglib.c b/source/texk/web2c/luatexdir/lua/limglib.c
index 44f1d72bff0c0badcc160efbeab94c1d767f1af8..eb9e4145a37cf76c1439546061f9ad1f881e4b81 100644
--- a/source/texk/web2c/luatexdir/lua/limglib.c
+++ b/source/texk/web2c/luatexdir/lua/limglib.c
@@ -298,17 +298,16 @@ void vf_out_image(PDF pdf, unsigned i)
 {
     image *a, **aa;
     image_dict *ad;
-    lua_State *L = Luas;
-    lua_rawgeti(L, LUA_REGISTRYINDEX, (int) i);
-    aa = (image **) luaL_checkudata(L, -1, TYPE_IMG);
+    lua_rawgeti(Luas, LUA_REGISTRYINDEX, (int) i);
+    aa = (image **) luaL_checkudata(Luas, -1, TYPE_IMG);
     a = *aa;
     ad = img_dict(a);
     if (ad == NULL) {
-        luaL_error(L, "invalid image dictionary");
+        luaL_error(Luas, "invalid image dictionary");
     }
     setup_image(pdf, a, WR_VF_IMG);
     place_img(pdf, ad, img_dimen(a), img_transform(a));
-    lua_pop(L, 1);
+    lua_pop(Luas, 1);
 }
 
 /* metamethods for image */
diff --git a/source/texk/web2c/luatexdir/lua/llanglib.c b/source/texk/web2c/luatexdir/lua/llanglib.c
index 3356e734189f793685a8d2128d12c0e7308c0643..27f3c84d25eee3a84a42b86e8e959ed1f001f46d 100644
--- a/source/texk/web2c/luatexdir/lua/llanglib.c
+++ b/source/texk/web2c/luatexdir/lua/llanglib.c
@@ -227,7 +227,7 @@ static int do_lang_clean(lua_State * L)
 {
     char *cleaned;
     if (lua_type(L, 1) == LUA_TSTRING) {
-        (void) clean_hyphenation(int_par(cur_lang_code), lua_tostring(L, 1), &cleaned);
+        (void) clean_hyphenation(cur_lang_par, lua_tostring(L, 1), &cleaned);
     } else {
         struct tex_language **lang_ptr;
         lang_ptr = check_islang(L, 1);
diff --git a/source/texk/web2c/luatexdir/lua/lnewtokenlib.c b/source/texk/web2c/luatexdir/lua/lnewtokenlib.c
index 561fef65e6616117d6eb76edb5915a736c9cd319..373f2d983820aa5a77ddb81f2775cbe87831e73c 100644
--- a/source/texk/web2c/luatexdir/lua/lnewtokenlib.c
+++ b/source/texk/web2c/luatexdir/lua/lnewtokenlib.c
@@ -63,7 +63,7 @@ typedef struct saved_tex_scanner {
 
 static lua_token *check_istoken(lua_State * L, int ud);
 
-#define TOKEN_METATABLE  "luatex_token"
+#define TOKEN_METATABLE  "luatex.token"
 
 #define DEBUG 0
 #define DEBUG_OUT stdout
@@ -534,7 +534,7 @@ static int run_build(lua_State * L)
     if (lua_type(L, 1) == LUA_TNUMBER) {
         int cs = 0;
         int chr = (int) lua_tointeger(L, 1);
-        int cmd = (int) luaL_optinteger(L, 2, get_cat_code(int_par(cat_code_table_code),chr));
+        int cmd = (int) luaL_optinteger(L, 2, get_cat_code(cat_code_table_par,chr));
         if (cmd == 0 || cmd == 9 || cmd == 14 || cmd == 15) {
             formatted_warning("token lib","not a good token, catcode %i can not be returned, so 12 will be used",(int) cmd);
             cmd = 12;
@@ -821,7 +821,7 @@ static int set_macro(lua_State * L)
         if (n > 3)
             s = lua_tostring(L, 4);
     } else {
-        ct = int_par(cat_code_table_code) ;
+        ct = cat_code_table_par;
         name = lua_tolstring(L, 1, &lname);
         if (n > 1)
             str = lua_tolstring(L, 2, &lstr);
diff --git a/source/texk/web2c/luatexdir/lua/lnodelib.c b/source/texk/web2c/luatexdir/lua/lnodelib.c
index a85be91c94c61a8cfdabadc275d1ae4e1f6498b6..c4706e4333179755b3dea867e2b494362fc99afd 100644
--- a/source/texk/web2c/luatexdir/lua/lnodelib.c
+++ b/source/texk/web2c/luatexdir/lua/lnodelib.c
@@ -170,7 +170,6 @@ while (vlink(t)!=current && t != null) { \
     t = vlink(t);                        \
 }
 
-#define box(A) eqtb[box_base+(A)].hh.rh
 #define direct_check_index_range(j,s)                                      \
     if (j<0 || j > 65535) {                                                \
         luaL_error(L, "incorrect index value %d for tex.%s()", (int)j, s); \
@@ -6568,12 +6567,12 @@ static int lua_nodelib_direct_setbox(lua_State * L)
         }
 
     }
-    save_global_defs = int_par(global_defs_code);
+    save_global_defs = global_defs_par;
     if (isglobal) {
-        int_par(global_defs_code) = 1;
+        global_defs_par = 1;
     }
     err = set_tex_box_register(k, j);
-    int_par(global_defs_code) = save_global_defs;
+    global_defs_par = save_global_defs;
     if (err) {
         luaL_error(L, "incorrect value");
     }
diff --git a/source/texk/web2c/luatexdir/lua/lpdflib.c b/source/texk/web2c/luatexdir/lua/lpdflib.c
index 2161d791108ed4a721c719b88d8451a46a890ca2..de82be7479ebb52dc0f8f01f562c4c4b06ec5063 100644
--- a/source/texk/web2c/luatexdir/lua/lpdflib.c
+++ b/source/texk/web2c/luatexdir/lua/lpdflib.c
@@ -950,6 +950,20 @@ static int getpdforigin(lua_State * L)
     return 2 ;
 }
 
+static int setpdfimageresolution(lua_State * L)
+{
+    if (lua_type(L, 1) == LUA_TNUMBER) {
+        set_tex_extension_count_register(c_pdf_image_resolution,lua_tointeger(L, 1));
+    }
+    return 0;
+}
+
+static int getpdfimageresolution(lua_State * L)
+{
+    lua_pushinteger(L,get_tex_extension_count_register(c_pdf_image_resolution));
+    return 1 ;
+}
+
 static int setpdfthreadmargin(lua_State * L) {
     if (lua_type(L, 1) == LUA_TNUMBER) {
         set_tex_extension_dimen_register(d_pdf_thread_margin,lua_tointeger(L, 1));
@@ -1065,6 +1079,24 @@ static int newpdfcolorstack(lua_State * L)
     return 1 ;
 }
 
+
+static int l_set_font_attributes(lua_State * L)
+{
+    int f = luaL_checkinteger(L, -2);
+    int i ;
+    /*char *s;*/
+    const char *st;
+    if ((lua_type(L,-1) == LUA_TSTRING) && (st = lua_tostring(L, -1)) != NULL) {
+        /* is this dup needed? */
+        /*s = xstrdup(st);*/
+        i = maketexstring(st); /* brrr */
+        set_pdf_font_attr(f, i);
+        /*free(s);*/
+    }
+    return 0;
+}
+
+
 static const struct luaL_Reg pdflib[] = {
     { "gethpos", l_gethpos },
     { "getvpos", l_getvpos },
@@ -1081,6 +1113,7 @@ static const struct luaL_Reg pdflib[] = {
     { "objtype", l_objtype },
     { "getmatrix", l_getmatrix },
     { "hasmatrix", l_hasmatrix },
+    { "setfontattributes", l_set_font_attributes },
     { "setcatalog", l_set_catalog },
     { "setinfo", l_set_info },
     { "setnames", l_set_names },
@@ -1126,6 +1159,8 @@ static const struct luaL_Reg pdflib[] = {
     { "newcolorstack", newpdfcolorstack },
     { "setorigin", setpdforigin },
     { "getorigin", getpdforigin },
+    { "setimageresolution", setpdfimageresolution },
+    { "getimageresolution", getpdfimageresolution },
     { "setthreadmargin", setpdfthreadmargin },
     { "setdestmargin", setpdfdestmargin },
     { "setlinkmargin", setpdflinkmargin },
diff --git a/source/texk/web2c/luatexdir/lua/ltexlib.c b/source/texk/web2c/luatexdir/lua/ltexlib.c
index 2de0c42b90d17c71ab9fd379e6566b389952ac96..0966176b1e2aee77885fc19f1c127cde6160a821 100644
--- a/source/texk/web2c/luatexdir/lua/ltexlib.c
+++ b/source/texk/web2c/luatexdir/lua/ltexlib.c
@@ -24,14 +24,6 @@ setter no prev link is created so we can presume that it's not used later on. */
 #include "ptexlib.h"
 #include "lua/luatex-api.h"
 
-#define attribute(A) eqtb[attribute_base+(A)].hh.rh
-#define dimen(A) eqtb[scaled_base+(A)].hh.rh
-#undef skip
-#define skip(A) eqtb[skip_base+(A)].hh.rh
-#define mu_skip(A) eqtb[mu_skip_base+(A)].hh.rh
-#define count(A) eqtb[count_base+(A)].hh.rh
-#define box(A) equiv(box_base+(A))
-
 /* tex random generators */
 extern int unif_rand(int );
 extern int norm_rand(void );
@@ -541,7 +533,7 @@ static const char *scan_dimen_part(lua_State * L, const char *ss, int *ret)
         v = (x_height(get_cur_font()));
     } else if (strncmp(s, "px", 2) == 0) {
         s += 2;
-        v = dimen_par(px_dimen_code);
+        v = px_dimen_par;
     } else {
         goto NOT_FOUND;
     }
@@ -562,9 +554,9 @@ static const char *scan_dimen_part(lua_State * L, const char *ss, int *ret)
         s += 4;
         if (output_mode_used <= OMODE_DVI) {
             prepare_mag();
-            if (int_par(mag_code) != 1000) {
-                cur_val = xn_over_d(cur_val, 1000, int_par(mag_code));
-                f = (1000 * f + 0200000 * tex_remainder) / int_par(mag_code);
+            if (mag_par != 1000) {
+                cur_val = xn_over_d(cur_val, 1000, mag_par);
+                f = (1000 * f + 0200000 * tex_remainder) / mag_par;
                 cur_val = cur_val + (f / 0200000);
                 f = f % 0200000;
             }
@@ -749,9 +741,9 @@ static int get_item_index(lua_State * L, int i, int base)
     size_t len;                                                                       \
     const char *str;                                                                  \
     int key, err, cs;                                                                 \
-    int save_global_defs = int_par(global_defs_code);                                 \
+    int save_global_defs = global_defs_par;                                           \
     if (is_global) {                                                                  \
-        int_par(global_defs_code) = 1;                                                \
+        global_defs_par = 1;                                                          \
     }                                                                                 \
     switch (lua_type(L, where)) {                                                     \
         case LUA_TSTRING:                                                             \
@@ -779,7 +771,7 @@ static int get_item_index(lua_State * L, int i, int base)
             }                                                                         \
             break;                                                                    \
         case LUA_TNUMBER:                                                             \
-            key = luaL_checkinteger(L, where);                                  \
+            key = luaL_checkinteger(L, where);                                        \
             if (key>=0 && key <= 65535) {                                             \
                 err = set_register(key, value);                                       \
                 if (err) {                                                            \
@@ -792,7 +784,7 @@ static int get_item_index(lua_State * L, int i, int base)
         default:                                                                      \
             luaL_error(L, "argument of 'set%s' must be a string or a number", what);  \
     }                                                                                 \
-    int_par(global_defs_code) = save_global_defs;                                     \
+    global_defs_par = save_global_defs;                                               \
 }
 
 static int gettex(lua_State * L);
@@ -1088,7 +1080,7 @@ static int settoks(lua_State * L)
     char *s;
     const char *ss;
     int is_global = 0;
-    int save_global_defs = int_par(global_defs_code);
+    int save_global_defs = global_defs_par;
     int n = lua_gettop(L);
     if (n == 3 && (lua_type(L,1) == LUA_TSTRING)) {
         const char *s = lua_tostring(L, 1);
@@ -1096,7 +1088,7 @@ static int settoks(lua_State * L)
             is_global = 1;
     }
     if (is_global)
-        int_par(global_defs_code) = 1;
+        global_defs_par = 1;
     i = lua_gettop(L);
     if (lua_type(L,i) != LUA_TSTRING) {
         luaL_error(L, "unsupported value type");
@@ -1109,7 +1101,7 @@ static int settoks(lua_State * L)
     check_index_range(k, "settoks");
     err = set_tex_toks_register(k, str);
     xfree(str.s);
-    int_par(global_defs_code) = save_global_defs;
+    global_defs_par = save_global_defs;
     if (err) {
         luaL_error(L, "incorrect value");
     }
@@ -1123,7 +1115,7 @@ static int scantoks(lua_State * L)
     char *s;
     const char *ss;
     int is_global = 0;
-    int save_global_defs = int_par(global_defs_code);
+    int save_global_defs = global_defs_par;
     int n = lua_gettop(L);
     if (n == 4 && (lua_type(L,1) == LUA_TSTRING)) {
         const char *s = lua_tostring(L, 1);
@@ -1132,7 +1124,7 @@ static int scantoks(lua_State * L)
     }
     /* action : vsettokscct(L, is_global); */
     if (is_global)
-        int_par(global_defs_code) = 1;
+        global_defs_par = 1;
     i = lua_gettop(L);
     if (lua_type(L,i) != LUA_TSTRING) {
         luaL_error(L, "unsupported value type");
@@ -1146,7 +1138,7 @@ static int scantoks(lua_State * L)
     check_index_range(k, "settoks");
     err = scan_tex_toks_register(k, c, str);
     xfree(str.s);
-    int_par(global_defs_code) = save_global_defs;
+    global_defs_par = save_global_defs;
     if (err) {
         luaL_error(L, "incorrect value");
     }
@@ -1243,9 +1235,9 @@ static int isbox(lua_State * L)
 static int vsetbox(lua_State * L, int is_global)
 {
     int j, k, err;
-    int save_global_defs = int_par(global_defs_code);
+    int save_global_defs = global_defs_par;
     if (is_global)
-        int_par(global_defs_code) = 1;
+        global_defs_par = 1;
     k = get_box_id(L, -2, true);
     check_index_range(k, "setbox");
     if (lua_isboolean(L, -1)) {
@@ -1263,7 +1255,7 @@ static int vsetbox(lua_State * L, int is_global)
 
     }
     err = set_tex_box_register(k, j);
-    int_par(global_defs_code) = save_global_defs;
+    global_defs_par = save_global_defs;
     if (err) {
         luaL_error(L, "incorrect value");
     }
@@ -1361,7 +1353,7 @@ static int setcatcode(lua_State * L)
     int ch;
     halfword val;
     int level = cur_level;
-    int cattable = int_par(cat_code_table_code);
+    int cattable = cat_code_table_par;
     int n = lua_gettop(L);
     int f = 1;
     if (n>1 && lua_type(L,1) == LUA_TTABLE)
@@ -1386,7 +1378,7 @@ static int setcatcode(lua_State * L)
 
 static int getcatcode(lua_State * L)
 {
-    int cattable = int_par(cat_code_table_code);
+    int cattable = cat_code_table_par;
     int ch = luaL_checkinteger(L, -1);
     if (lua_gettop(L)>=2 && lua_type(L,-2)==LUA_TNUMBER) {
         cattable = luaL_checkinteger(L, -2);
@@ -1860,7 +1852,7 @@ static int getromannumeral(lua_State * L)
 
 static int get_parshape(lua_State * L)
 {
-    halfword par_shape_ptr = equiv(par_shape_loc);
+    halfword par_shape_ptr = par_shape_par_ptr;
     if (par_shape_ptr != 0) {
         int m = 1;
         int n = vinfo(par_shape_ptr + 1);
@@ -2591,27 +2583,27 @@ static int tex_run_linebreak(lua_State * L)
     }
     lua_pop(L, 1);
 
-    get_int_par  (pretolerance, int_par(pretolerance_code));
-    get_int_par  (tracingparagraphs, int_par(tracing_paragraphs_code));
-    get_int_par  (tolerance, int_par(tolerance_code));
-    get_int_par  (looseness, int_par(looseness_code));
-    get_int_par  (adjustspacing, int_par(adjust_spacing_code));
-    get_int_par  (adjdemerits, int_par(adj_demerits_code));
-    get_int_par  (protrudechars, int_par(protrude_chars_code));
-    get_int_par  (linepenalty, int_par(line_penalty_code));
-    get_int_par  (lastlinefit, int_par(last_line_fit_code));
-    get_int_par  (doublehyphendemerits, int_par(double_hyphen_demerits_code));
-    get_int_par  (finalhyphendemerits, int_par(final_hyphen_demerits_code));
-    get_int_par  (hangafter, int_par(hang_after_code));
-    get_intx_par (interlinepenalty,int_par(inter_line_penalty_code), interlinepenalties, equiv(inter_line_penalties_loc));
-    get_intx_par (clubpenalty, int_par(club_penalty_code), clubpenalties, equiv(club_penalties_loc));
-    get_intx_par (widowpenalty, int_par(widow_penalty_code), widowpenalties, equiv(widow_penalties_loc));
-    get_int_par  (brokenpenalty, int_par(broken_penalty_code));
-    get_dimen_par(emergencystretch, dimen_par(emergency_stretch_code));
-    get_dimen_par(hangindent, dimen_par(hang_indent_code));
-    get_dimen_par(hsize, dimen_par(hsize_code));
-    get_glue_par (leftskip, glue_par(left_skip_code));
-    get_glue_par (rightskip, glue_par(right_skip_code));
+    get_int_par  (pretolerance, pretolerance_par);
+    get_int_par  (tracingparagraphs, tracing_paragraphs_par);
+    get_int_par  (tolerance, tolerance_par);
+    get_int_par  (looseness, looseness_par);
+    get_int_par  (adjustspacing, adjust_spacing_par);
+    get_int_par  (adjdemerits, adj_demerits_par);
+    get_int_par  (protrudechars, protrude_chars_par);
+    get_int_par  (linepenalty, line_penalty_par);
+    get_int_par  (lastlinefit, last_line_fit_par);
+    get_int_par  (doublehyphendemerits, double_hyphen_demerits_par);
+    get_int_par  (finalhyphendemerits, final_hyphen_demerits_par);
+    get_int_par  (hangafter, hang_after_par);
+    get_intx_par (interlinepenalty,inter_line_penalty_par, interlinepenalties, equiv(inter_line_penalties_loc));
+    get_intx_par (clubpenalty, club_penalty_par, clubpenalties, equiv(club_penalties_loc));
+    get_intx_par (widowpenalty, widow_penalty_par, widowpenalties, equiv(widow_penalties_loc));
+    get_int_par  (brokenpenalty, broken_penalty_par);
+    get_dimen_par(emergencystretch, emergency_stretch_par);
+    get_dimen_par(hangindent, hang_indent_par);
+    get_dimen_par(hsize, hsize_par);
+    get_glue_par (leftskip, left_skip_par);
+    get_glue_par (rightskip, right_skip_par);
     ext_do_line_break(paragraph_dir,
                       pretolerance,
                       tracingparagraphs,
@@ -2827,6 +2819,7 @@ static int tex_save_box_resource(lua_State * L)
     int index = null;
     int attributes = null;
     int resources = null;
+    int type = 0;
     boolean immediate = false;
     /* box attributes resources */
     halfword boxnumber = lua_tointeger(L,1);
@@ -2841,6 +2834,9 @@ static int tex_save_box_resource(lua_State * L)
     if (lua_type(L,4) == LUA_TBOOLEAN) {
         immediate = lua_toboolean(L, 4);
     }
+    if (lua_type(L,5) == LUA_TNUMBER) {
+        type = lua_tointeger(L, 5);
+    }
     /* more or less same as scanner variant */
     boxdata = box(boxnumber);
     if (boxdata == null)
@@ -2856,6 +2852,7 @@ static int tex_save_box_resource(lua_State * L)
     set_obj_xform_width(static_pdf, index, width(boxdata));
     set_obj_xform_height(static_pdf, index, height(boxdata));
     set_obj_xform_depth(static_pdf, index, depth(boxdata));
+    set_obj_xform_type(static_pdf, index, type);
     box(boxnumber) = null;
     last_saved_box_index = index;
     lua_pushinteger(L, index);
diff --git a/source/texk/web2c/luatexdir/lua/luanode.w b/source/texk/web2c/luatexdir/lua/luanode.w
index 3325245fcaa1cbf564b685c9df9254592af46b56..39b68a686144d6db42907aad32e116e140f12ce5 100644
--- a/source/texk/web2c/luatexdir/lua/luanode.w
+++ b/source/texk/web2c/luatexdir/lua/luanode.w
@@ -28,109 +28,57 @@ nodes are removed or inserted, temp nodes don't interfere */
 @ @c
 void lua_node_filter_s(int filterid, int extrainfo)
 {
-    lua_State *L = Luas;
     int callback_id = callback_defined(filterid);
-    int s_top = lua_gettop(L);
+    int s_top = lua_gettop(Luas);
     if (callback_id <= 0) {
-        lua_settop(L, s_top);
+        lua_settop(Luas, s_top);
         return;
     }
-    if (!get_callback(L, callback_id)) {
-        lua_settop(L, s_top);
+    if (!get_callback(Luas, callback_id)) {
+        lua_settop(Luas, s_top);
         return;
     }
-    lua_push_string_by_index(L,extrainfo); /* arg 1 */
-    if (lua_pcall(L, 1, 0, 0) != 0) {
-        fprintf(stdout, "error: %s\n", lua_tostring(L, -1));
-        lua_settop(L, s_top);
+    lua_push_string_by_index(Luas,extrainfo); /* arg 1 */
+    if (lua_pcall(Luas, 1, 0, 0) != 0) {
+        fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1));
+        lua_settop(Luas, s_top);
         error();
         return;
     }
-    lua_settop(L, s_top);
+    lua_settop(Luas, s_top);
     return;
 }
 
 @ @c
-/*
-void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * tail_node)
-{
-    halfword ret;
-    int a;
-    lua_State *L = Luas;
-    int s_top = lua_gettop(L);
-    int callback_id = callback_defined(filterid);
-    if (head_node == null || vlink(head_node) == null || callback_id <= 0) {
-	lua_settop(L, s_top);
-        return;
-    }
-    if (!get_callback(L, callback_id)) {
-        lua_settop(L, s_top);
-        return;
-    }
-    alink(vlink(head_node)) = null ;
-    nodelist_to_lua(L, vlink(head_node));
-    lua_push_group_code(L,extrainfo);
-    if (lua_pcall(L, 2, 1, 0) != 0) {
-        fprintf(stdout, "error: %s\n", lua_tostring(L, -1));
-        lua_settop(L, s_top);
-        error();
-        return;
-    }
-    if (lua_isboolean(L, -1)) {
-        if (lua_toboolean(L, -1) != 1) {
-            flush_node_list(vlink(head_node));
-            vlink(head_node) = null;
-        }
-    } else {
-        a = nodelist_from_lua(L);
-        try_couple_nodes(head_node,a);
-    }
-    lua_pop(L, 2);
-    if (fix_node_lists)
-        fix_node_list(head_node);
-    ret = vlink(head_node);
-    if (ret != null) {
-        while (vlink(ret) != null)
-            ret = vlink(ret);
-        *tail_node = ret;
-    } else {
-        *tail_node = head_node;
-    }
-    lua_settop(L, s_top);
-    return;
-}
-*/
-
 void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * tail_node)
 {
     halfword start_node, start_done, last_node;
-    lua_State *L = Luas;
-    int s_top = lua_gettop(L);
+    int s_top = lua_gettop(Luas);
     int callback_id = callback_defined(filterid);
     if (head_node == null || callback_id <= 0) {
-        lua_settop(L, s_top);
+        lua_settop(Luas, s_top);
         return;
     }
     /* we start after head */
     start_node = vlink(head_node);
-    if (start_node == null || !get_callback(L, callback_id)) {
-        lua_settop(L, s_top);
+    if (start_node == null || !get_callback(Luas, callback_id)) {
+        lua_settop(Luas, s_top);
         return;
     }
     /* we make sure we have no prev */
     alink(start_node) = null ;
     /* the action */
-    nodelist_to_lua(L, start_node);
-    lua_push_group_code(L,extrainfo);
-    if (lua_pcall(L, 2, 1, 0) != 0) {
-        fprintf(stdout, "error: %s\n", lua_tostring(L, -1));
-        lua_settop(L, s_top);
+    nodelist_to_lua(Luas, start_node);
+    lua_push_group_code(Luas,extrainfo);
+    if (lua_pcall(Luas, 2, 1, 0) != 0) {
+        fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1));
+        lua_settop(Luas, s_top);
         error();
         return;
     }
     /* the result */
-    if (lua_isboolean(L, -1)) {
-        if (lua_toboolean(L, -1) != 1) {
+    if (lua_isboolean(Luas, -1)) {
+        if (lua_toboolean(Luas, -1) != 1) {
             /* discard */
             flush_node_list(start_node);
             vlink(head_node) = null;
@@ -139,11 +87,11 @@ void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword *
         }
     } else {
         /* append to old head */
-        start_done = nodelist_from_lua(L);
+        start_done = nodelist_from_lua(Luas);
         try_couple_nodes(head_node,start_done);
     }
     /* redundant as we set top anyway */
-    lua_pop(L, 2);
+    lua_pop(Luas, 2);
     /* find tail in order to update tail */
     start_node = vlink(head_node);
     if (start_node != null) {
@@ -168,7 +116,7 @@ void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword *
         *tail_node = head_node;
     }
     /* clean up */
-    lua_settop(L, s_top);
+    lua_settop(Luas, s_top);
     return;
 }
 
@@ -178,33 +126,32 @@ int lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_hea
     int a;
     register halfword *p;
     int ret = 0;                /* failure */
-    lua_State *L = Luas;
-    int s_top = lua_gettop(L);
+    int s_top = lua_gettop(Luas);
     int callback_id = callback_defined(linebreak_filter_callback);
     if (head_node == null || vlink(head_node) == null || callback_id <= 0) {
-        lua_settop(L, s_top);
+        lua_settop(Luas, s_top);
         return ret;
     }
-    if (!get_callback(L, callback_id)) {
-       lua_settop(L, s_top);
+    if (!get_callback(Luas, callback_id)) {
+       lua_settop(Luas, s_top);
         return ret;
     }
     alink(vlink(head_node)) = null ; /* hh-ls */
-    nodelist_to_lua(L, vlink(head_node));       /* arg 1 */
-    lua_pushboolean(L, is_broken);      /* arg 2 */
-    if (lua_pcall(L, 2, 1, 0) != 0) {   /* no arg, 1 result */
-        fprintf(stdout, "error: %s\n", lua_tostring(L, -1));
-        lua_settop(L, s_top);
+    nodelist_to_lua(Luas, vlink(head_node));       /* arg 1 */
+    lua_pushboolean(Luas, is_broken);      /* arg 2 */
+    if (lua_pcall(Luas, 2, 1, 0) != 0) {   /* no arg, 1 result */
+        fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1));
+        lua_settop(Luas, s_top);
         error();
         return ret;
     }
-    p = lua_touserdata(L, -1);
+    p = lua_touserdata(Luas, -1);
     if (p != NULL) {
-        a = nodelist_from_lua(L);
+        a = nodelist_from_lua(Luas);
         try_couple_nodes(*new_head,a);
         ret = 1;
     }
-    lua_settop(L, s_top);
+    lua_settop(Luas, s_top);
     return ret;
 }
 
@@ -212,39 +159,38 @@ int lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_hea
 int lua_appendtovlist_callback(halfword box, int location, halfword prev_depth, boolean is_mirrored, halfword * result, int * next_depth, boolean * prev_set)
 {
     register halfword *p;
-    lua_State *L = Luas;
-    int s_top = lua_gettop(L);
+    int s_top = lua_gettop(Luas);
     int callback_id = callback_defined(append_to_vlist_filter_callback);
     if (box == null || callback_id <= 0) {
-        lua_settop(L, s_top);
+        lua_settop(Luas, s_top);
         return 0;
     }
-    if (!get_callback(L, callback_id)) {
-        lua_settop(L, s_top);
+    if (!get_callback(Luas, callback_id)) {
+        lua_settop(Luas, s_top);
         return 0;
     }
-    nodelist_to_lua(L, box);
-    lua_push_string_by_index(L,location);
-    lua_pushinteger(L, (int) prev_depth);
-    lua_pushboolean(L, is_mirrored);
-    if (lua_pcall(L, 4, 2, 0) != 0) {
-        fprintf(stdout, "error: %s\n", lua_tostring(L, -1));
-        lua_settop(L, s_top);
+    nodelist_to_lua(Luas, box);
+    lua_push_string_by_index(Luas,location);
+    lua_pushinteger(Luas, (int) prev_depth);
+    lua_pushboolean(Luas, is_mirrored);
+    if (lua_pcall(Luas, 4, 2, 0) != 0) {
+        fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1));
+        lua_settop(Luas, s_top);
         error();
         return 0;
     }
-    if (lua_type(L,-1) == LUA_TNUMBER) {
-        *next_depth = lua_tointeger(L,-1);
+    if (lua_type(Luas,-1) == LUA_TNUMBER) {
+        *next_depth = lua_tointeger(Luas,-1);
         *prev_set = true;
-        if (lua_type(L, -2) != LUA_TNIL) {
-            p = check_isnode(L, -2);
+        if (lua_type(Luas, -2) != LUA_TNIL) {
+            p = check_isnode(Luas, -2);
             *result = *p;
         }
-    } else if (lua_type(L, -1) != LUA_TNIL) {
-        p = check_isnode(L, -1);
+    } else if (lua_type(Luas, -1) != LUA_TNIL) {
+        p = check_isnode(Luas, -1);
         *result = *p;
     }
-    lua_settop(L, s_top);
+    lua_settop(Luas, s_top);
     return 1;
 }
 
@@ -252,50 +198,49 @@ int lua_appendtovlist_callback(halfword box, int location, halfword prev_depth,
 halfword lua_hpack_filter(halfword head_node, scaled size, int pack_type, int extrainfo, int pack_direction, halfword attr)
 {
     halfword ret;
-    lua_State *L = Luas;
-    int s_top = lua_gettop(L);
+    int s_top = lua_gettop(Luas);
     int callback_id = callback_defined(hpack_filter_callback);
     if (head_node == null || callback_id <= 0) {
-        lua_settop(L, s_top);
+        lua_settop(Luas, s_top);
         return head_node;
     }
-    if (!get_callback(L, callback_id)) {
-        lua_settop(L, s_top);
+    if (!get_callback(Luas, callback_id)) {
+        lua_settop(Luas, s_top);
         return head_node;
     }
     alink(head_node) = null ; /* hh-ls */
-    nodelist_to_lua(L, head_node);
-    lua_push_group_code(L,extrainfo);
-    lua_pushinteger(L, size);
-    lua_push_pack_type(L,pack_type);
+    nodelist_to_lua(Luas, head_node);
+    lua_push_group_code(Luas,extrainfo);
+    lua_pushinteger(Luas, size);
+    lua_push_pack_type(Luas, pack_type);
     if (pack_direction >= 0) {
-        lua_push_dir_par(L, pack_direction);
+        lua_push_dir_par(Luas, pack_direction);
     } else {
-        lua_pushnil(L);
+        lua_pushnil(Luas);
     }
     if (attr != null) {
-        nodelist_to_lua(L, attr);
+        nodelist_to_lua(Luas, attr);
     } else {
-        lua_pushnil(L);
+        lua_pushnil(Luas);
     }
-    if (lua_pcall(L, 6, 1, 0) != 0) {
-        fprintf(stdout, "error: %s\n", lua_tostring(L, -1));
-        lua_settop(L, s_top);
+    if (lua_pcall(Luas, 6, 1, 0) != 0) {
+        fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1));
+        lua_settop(Luas, s_top);
         error();
         return head_node;
     }
     ret = head_node;
-    if (lua_isboolean(L, -1)) {
-        if (lua_toboolean(L, -1) != 1) {
+    if (lua_isboolean(Luas, -1)) {
+        if (lua_toboolean(Luas, -1) != 1) {
             flush_node_list(head_node);
             ret = null;
         }
     } else {
-        ret = nodelist_from_lua(L);
+        ret = nodelist_from_lua(Luas);
     }
-    lua_settop(L, s_top);
+    lua_settop(Luas, s_top);
 #if 0
-    lua_gc(L,LUA_GCSTEP, LUA_GC_STEP_SIZE);
+    lua_gc(Luas,LUA_GCSTEP, LUA_GC_STEP_SIZE);
 #endif
     if (fix_node_lists)
         fix_node_list(ret);
@@ -308,10 +253,9 @@ halfword lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled
 {
     halfword ret;
     int callback_id;
-    lua_State *L = Luas;
-    int s_top = lua_gettop(L);
+    int s_top = lua_gettop(Luas);
     if (head_node == null) {
-        lua_settop(L, s_top);
+        lua_settop(Luas, s_top);
         return head_node;
     }
     if  (extrainfo == 8)  { /* output */
@@ -320,47 +264,47 @@ halfword lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled
         callback_id = callback_defined(vpack_filter_callback);
     }
     if (callback_id <= 0) {
-        lua_settop(L, s_top);
+        lua_settop(Luas, s_top);
         return head_node;
     }
-    if (!get_callback(L, callback_id)) {
-        lua_settop(L, s_top);
+    if (!get_callback(Luas, callback_id)) {
+        lua_settop(Luas, s_top);
         return head_node;
     }
     alink(head_node) = null ; /* hh-ls */
-    nodelist_to_lua(L, head_node);
-    lua_push_group_code(L,extrainfo);
-    lua_pushinteger(L, size);
-    lua_push_pack_type(L,pack_type);
-    lua_pushinteger(L, maxd);
+    nodelist_to_lua(Luas, head_node);
+    lua_push_group_code(Luas, extrainfo);
+    lua_pushinteger(Luas, size);
+    lua_push_pack_type(Luas, pack_type);
+    lua_pushinteger(Luas, maxd);
     if (pack_direction >= 0) {
-         lua_push_dir_par(L, pack_direction);
+         lua_push_dir_par(Luas, pack_direction);
     } else {
-        lua_pushnil(L);
+        lua_pushnil(Luas);
     }
     if (attr != null) {
-        nodelist_to_lua(L, attr);
+        nodelist_to_lua(Luas, attr);
     } else {
-        lua_pushnil(L);
+        lua_pushnil(Luas);
     }
-    if (lua_pcall(L, 7, 1, 0) != 0) {
-        fprintf(stdout, "error: %s\n", lua_tostring(L, -1));
-        lua_settop(L, s_top);
+    if (lua_pcall(Luas, 7, 1, 0) != 0) {
+        fprintf(stdout, "error: %s\n", lua_tostring(Luas, -1));
+        lua_settop(Luas, s_top);
         error();
         return head_node;
     }
     ret = head_node;
-    if (lua_isboolean(L, -1)) {
-        if (lua_toboolean(L, -1) != 1) {
+    if (lua_isboolean(Luas, -1)) {
+        if (lua_toboolean(Luas, -1) != 1) {
             flush_node_list(head_node);
             ret = null;
         }
     } else {
-        ret = nodelist_from_lua(L);
+        ret = nodelist_from_lua(Luas);
     }
-    lua_settop(L, s_top);
+    lua_settop(Luas, s_top);
 #if 0
-    lua_gc(L,LUA_GCSTEP, LUA_GC_STEP_SIZE);
+    lua_gc(Luas,LUA_GCSTEP, LUA_GC_STEP_SIZE);
 #endif
     if (fix_node_lists)
         fix_node_list(ret);
diff --git a/source/texk/web2c/luatexdir/lua/luatex-api.h b/source/texk/web2c/luatexdir/lua/luatex-api.h
index 30a9cc4c28a55b7eae9b3a7ce4e51282150dfae2..cf3740101dab1fc02526f1517dbacd510f96cc0f 100644
--- a/source/texk/web2c/luatexdir/lua/luatex-api.h
+++ b/source/texk/web2c/luatexdir/lua/luatex-api.h
@@ -1185,6 +1185,7 @@ init_lua_key_alias(empty_string,"");\
 init_lua_key_alias(lua_bytecodes_indirect,"lua.bytecodes.indirect");\
 init_lua_key_alias(lua_functions,"lua.functions");\
 init_lua_key_alias(luatex_node, "luatex.node");\
+init_lua_key_alias(luatex_token, "luatex.token");\
 init_lua_key_alias(mLTL,"-LTL");\
 init_lua_key_alias(mRTT,"-RTT");\
 init_lua_key_alias(mTLT,"-TLT");\
diff --git a/source/texk/web2c/luatexdir/lua/luatoken.w b/source/texk/web2c/luatexdir/lua/luatoken.w
index 893519b592508f25301b97f376851ad243f8b39c..a567c7f7a2bf0e52bd11b08f52b88031be51c8a5 100644
--- a/source/texk/web2c/luatexdir/lua/luatoken.w
+++ b/source/texk/web2c/luatexdir/lua/luatoken.w
@@ -113,6 +113,7 @@ command_item command_names[] = {
     {"assign_mu_glue", assign_mu_glue_cmd, NULL},
     {"assign_font_dimen", assign_font_dimen_cmd, NULL},
     {"assign_font_int", assign_font_int_cmd, NULL},
+    {"assign_hang_indent", assign_hang_indent_cmd, NULL},
     {"set_aux", set_aux_cmd, NULL},
     {"set_prev_graf", set_prev_graf_cmd, NULL},
     {"set_page_dimen", set_page_dimen_cmd, NULL},
@@ -362,34 +363,33 @@ int tokenlist_from_lua(lua_State * L)
 
 static void do_get_token_lua(int callback_id)
 {
-    lua_State *L = Luas;
     while (1) {
-        if (!get_callback(L, callback_id)) {
+        if (!get_callback(Luas, callback_id)) {
             get_next();
-            lua_pop(L, 2);
+            lua_pop(Luas, 2);
             break;
         }
-        if (lua_pcall(L, 0, 1, 0) != 0) {
-            tex_error(lua_tostring(L, -1), NULL);
-            lua_pop(L, 2);
+        if (lua_pcall(Luas, 0, 1, 0) != 0) {
+            tex_error(lua_tostring(Luas, -1), NULL);
+            lua_pop(Luas, 2);
             break;
         }
-        if (lua_istable(L, -1)) {
-            lua_rawgeti(L, -1, 1);
-            if (lua_istable(L, -1)) {
+        if (lua_istable(Luas, -1)) {
+            lua_rawgeti(Luas, -1, 1);
+            if (lua_istable(Luas, -1)) {
                 int p, q, r;
                 size_t i, j;
-                lua_pop(L, 1);
+                lua_pop(Luas, 1);
                 r = get_avail();
                 p = r;
-                j = lua_rawlen(L, -1);
+                j = lua_rawlen(Luas, -1);
                 if (j > 0) {
                     for (i = 1; i <= j; i++) {
-                        lua_rawgeti(L, -1, (int) i);
-                        if (get_cur_cmd(L) || get_cur_cs(L)) {
+                        lua_rawgeti(Luas, -1, (int) i);
+                        if (get_cur_cmd(Luas) || get_cur_cs(Luas)) {
                             store_new_token(cur_tok);
                         }
-                        lua_pop(L, 1);
+                        lua_pop(Luas, 1);
                     }
                 }
                 if (p != r) {
@@ -399,23 +399,22 @@ static void do_get_token_lua(int callback_id)
                     cur_input.nofilter_field = true;
                     get_next();
                 } else {
-                    tex_error("error: illegal or empty token list returned",
-                              NULL);
+                    tex_error("error: illegal or empty token list returned", NULL);
                 }
-                lua_pop(L, 2);
+                lua_pop(Luas, 2);
                 break;
             } else {
-                lua_pop(L, 1);
-                if (get_cur_cmd(L) || get_cur_cs(L)) {
-                    lua_pop(L, 2);
+                lua_pop(Luas, 1);
+                if (get_cur_cmd(Luas) || get_cur_cs(Luas)) {
+                    lua_pop(Luas, 2);
                     break;
                 } else {
-                    lua_pop(L, 2);
+                    lua_pop(Luas, 2);
                     continue;
                 }
             }
         } else {
-            lua_pop(L, 2);
+            lua_pop(Luas, 2);
         }
     }
     return;
diff --git a/source/texk/web2c/luatexdir/pdf/pdfannot.w b/source/texk/web2c/luatexdir/pdf/pdfannot.w
index 6bbfec226e73509f606b5fa58d3b1ba786cdc46c..43ee3692bd1114a7e9785f680a55e143c6949892 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfannot.w
+++ b/source/texk/web2c/luatexdir/pdf/pdfannot.w
@@ -22,8 +22,6 @@
 #include "ptexlib.h"
 
 @ @c
-#define tail cur_list.tail_field
-
 void do_annot(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
 {
     scaled_whd alt_rule;
@@ -52,15 +50,15 @@ void do_annot(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
     scaled_whd alt_rule;
     new_whatsit(w);
     alt_rule = scan_alt_rule(); /* scans |<rule spec>| to |alt_rule| */
-    set_width(tail, alt_rule.wd);
-    set_height(tail, alt_rule.ht);
-    set_depth(tail, alt_rule.dp);
+    set_width(tail_par, alt_rule.wd);
+    set_height(tail_par, alt_rule.ht);
+    set_depth(tail_par, alt_rule.dp);
     if ((w == pdf_thread_node) || (w == pdf_start_thread_node)) {
         if (scan_keyword("attr")) {
             scan_toks(false, true);
-            set_pdf_thread_attr(tail, def_ref);
+            set_pdf_thread_attr(tail_par, def_ref);
         } else {
-            set_pdf_thread_attr(tail, null);
+            set_pdf_thread_attr(tail_par, null);
         }
     }
 }
@@ -87,10 +85,10 @@ void do_annot(PDF pdf, halfword p, halfword parent_box, scaledpos cur)
             k = pdf_create_obj(pdf, obj_type_annot, 0);
         }
         new_annot_whatsit(pdf_annot_node);
-        obj_annot_ptr(pdf, k) = tail;
-        set_pdf_annot_objnum(tail, k);
+        obj_annot_ptr(pdf, k) = tail_par;
+        set_pdf_annot_objnum(tail_par, k);
         scan_toks(false, true);
-        set_pdf_annot_data(tail, def_ref);
+        set_pdf_annot_data(tail_par, def_ref);
     }
     pdf_last_annot = k;
 }
diff --git a/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w b/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
index bcc7145c6ce3b8c4ad8f9613954ee1285ed4507d..ac117d6ba0517564a00be4fe67ea49f175cdf2c2 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
+++ b/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w
@@ -47,9 +47,6 @@ They have the following properties:
 */
 
 #define COLOR_DEFAULT "0 g 0 G"
-#define SET_ORIGIN    0
-#define DIRECT_PAGE   1
-#define DIRECT_ALWAYS 2
 
 typedef struct {
     char **page_stack;
@@ -89,7 +86,7 @@ static void colstacks_first_init(void)
     colstacks[0].page_current = xstrdup(COLOR_DEFAULT);
     colstacks[0].form_current = xstrdup(COLOR_DEFAULT);
     colstacks[0].form_init = xstrdup(COLOR_DEFAULT);
-    colstacks[0].literal_mode = DIRECT_ALWAYS;
+    colstacks[0].literal_mode = direct_always;
     colstacks[0].page_start = true;
 }
 
diff --git a/source/texk/web2c/luatexdir/pdf/pdfgen.w b/source/texk/web2c/luatexdir/pdf/pdfgen.w
index addca7458e0f62a4f63077583eaf8f019ea5650a..e27928a9e18a1068f9965eb561b1dfcd5b77a39c 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfgen.w
+++ b/source/texk/web2c/luatexdir/pdf/pdfgen.w
@@ -26,8 +26,6 @@
 #include "lua/luatex-api.h"
 #include "md5.h"
 
-#define is_hex_char isxdigit
-
 #define check_nprintf(size_get, size_want) \
     if ((unsigned)(size_get) >= (unsigned)(size_want)) \
         formatted_error("pdf backend","snprintf() failed in file %s at line %d", __FILE__, __LINE__);
@@ -246,7 +244,7 @@ int pdf_get_mem(PDF pdf, int s)
 output_mode get_o_mode(void)
 {
     output_mode o_mode;
-    if (int_par(output_mode_code) > 0) {
+    if (output_mode_par > 0) {
         o_mode = OMODE_PDF;
     } else
         o_mode = OMODE_DVI;
@@ -286,7 +284,7 @@ void fix_pdf_minorversion(PDF pdf)
         /* Check that variables for \.{PDF} output are unchanged */
         if (pdf->minor_version != pdf_minor_version)
             normal_error("pdf backend", "minorversion cannot be changed after data is written to the PDF file");
-        if (pdf->draftmode != int_par(draft_mode_code))
+        if (pdf->draftmode != draft_mode_par)
             normal_error("pdf backend", "draftmode cannot be changed after data is written to the PDF file");
     }
     if (pdf->draftmode != 0) {
@@ -634,7 +632,7 @@ void pdf_print_str(PDF pdf, const char *s)
         return;
     }
     s++;
-    while (is_hex_char((unsigned char)*s))
+    while (isxdigit((unsigned char)*s))
         s++;
     if (s != orig + l) {
         pdf_out(pdf, '(');
@@ -961,7 +959,7 @@ void pdf_rectangle(PDF pdf, halfword r)
 static void init_pdf_outputparameters(PDF pdf)
 {
     int pk_mode;
-    pdf->draftmode = fix_int(int_par(draft_mode_code), 0, 1);
+    pdf->draftmode = fix_int(draft_mode_par, 0, 1);
     pdf->compress_level = fix_int(pdf_compress_level, 0, 9);
     pdf->decimal_digits = fix_int(pdf_decimal_digits, 3, 5);
     pdf->gamma = fix_int(pdf_gamma, 0, 1000000);
@@ -988,15 +986,17 @@ static void init_pdf_outputparameters(PDF pdf)
         pk_mode = pdf_pk_mode; /* lookup once */
         if (pk_mode != null) {
             char *s = tokenlist_to_cstring(pk_mode, true, NULL);
+            /* This will become LUATEX in 1.0. */
             kpse_init_prog("PDFTEX", (unsigned) pdf->pk_resolution, s, nil);
             xfree(s);
         } else {
+            /* This will become LUATEX in 1.0. */
             kpse_init_prog("PDFTEX", (unsigned) pdf->pk_resolution, nil, nil);
         }
         if (!kpse_var_value("MKTEXPK"))
             kpse_set_program_enabled(kpse_pk_format, 1, kpse_src_cmdline);
     }
-    set_job_id(pdf, int_par(year_code), int_par(month_code), int_par(day_code), int_par(time_code));
+    set_job_id(pdf, year_par, month_par, day_par, time_par);
     if ((pdf_unique_resname > 0) && (pdf->resname_prefix == NULL))
         pdf->resname_prefix = get_resname_prefix(pdf);
 }
@@ -1027,6 +1027,7 @@ static void ensure_pdf_header_written(PDF pdf)
     init_pdf_outputparameters(pdf);
     /* Write \.{PDF} header */
     pdf_printf(pdf, "%%PDF-1.%d\n", pdf->minor_version);
+    /* The next blob will be removed 1.0. */
     pdf_out(pdf, '%');
     pdf_out(pdf, 'P' + 128);
     pdf_out(pdf, 'T' + 128);
@@ -1647,9 +1648,9 @@ void check_o_mode(PDF pdf, const char *s, int o_mode_bitpattern, boolean strict)
                normal_error("pdf backend","weird output state");
          }
         if (strict)
-            formatted_error("pdf backend", "%s not allowed in %s mode (outputmode = %d)",s, m, (int) int_par(output_mode_code));
+            formatted_error("pdf backend", "%s not allowed in %s mode (outputmode = %d)",s, m, (int) output_mode_par);
         else
-            formatted_warning("pdf backend", "%s not allowed in %s mode (outputmode = %d)",s, m, (int) int_par(output_mode_code));
+            formatted_warning("pdf backend", "%s not allowed in %s mode (outputmode = %d)",s, m, (int) output_mode_par);
     } else if (strict)
         ensure_output_state(pdf, ST_HEADER_WRITTEN);
 }
@@ -1693,11 +1694,10 @@ char *get_resname_prefix(PDF pdf)
 }
 
 @ @c
-#define mag int_par(mag_code)
-
 void pdf_begin_page(PDF pdf)
 {
     int xform_attributes;
+    int xform_type = 0;
     scaled form_margin = pdf_xform_margin; /* was one_bp until SVN4066 */
     ensure_output_state(pdf, ST_HEADER_WRITTEN);
     init_pdf_pagecalculations(pdf);
@@ -1716,12 +1716,16 @@ void pdf_begin_page(PDF pdf)
         pdf->last_thread = null;
         pdf_begin_dict(pdf);
     } else {
+        xform_type = obj_xform_type(pdf, pdf_cur_form) ;
         pdf_begin_obj(pdf, pdf_cur_form, OBJSTM_NEVER);
         pdf->last_stream = pdf_cur_form;
         /* Write out Form stream header */
         pdf_begin_dict(pdf);
-        pdf_dict_add_name(pdf, "Type", "XObject");
-        pdf_dict_add_name(pdf, "Subtype", "Form");
+        if (xform_type == 0) {
+            pdf_dict_add_name(pdf, "Type", "XObject");
+            pdf_dict_add_name(pdf, "Subtype", "Form");
+            pdf_dict_add_int(pdf, "FormType", 1);
+        }
         xform_attributes = pdf_xform_attr; /* lookup once */
         if (xform_attributes != null)
             pdf_print_toks(pdf, xform_attributes);
@@ -1735,23 +1739,26 @@ void pdf_begin_page(PDF pdf)
             luaL_unref(Luas, LUA_REGISTRYINDEX, obj_xform_attr_str(pdf, pdf_cur_form));
             set_obj_xform_attr_str(pdf, pdf_cur_form, null);
         }
-        pdf_add_name(pdf, "BBox");
-        pdf_begin_array(pdf);
-        pdf_add_bp(pdf, -form_margin);
-        pdf_add_bp(pdf, -form_margin);
-        pdf_add_bp(pdf, pdf->page_size.h + form_margin);
-        pdf_add_bp(pdf, pdf->page_size.v + form_margin);
-        pdf_end_array(pdf);
-        pdf_dict_add_int(pdf, "FormType", 1);
-        pdf_add_name(pdf, "Matrix");
-        pdf_begin_array(pdf);
-        pdf_add_int(pdf, 1);
-        pdf_add_int(pdf, 0);
-        pdf_add_int(pdf, 0);
-        pdf_add_int(pdf, 1);
-        pdf_add_int(pdf, 0);
-        pdf_add_int(pdf, 0);
-        pdf_end_array(pdf);
+        if (xform_type == 0 || xform_type == 1 || xform_type == 3) {
+            pdf_add_name(pdf, "BBox");
+            pdf_begin_array(pdf);
+            pdf_add_bp(pdf, -form_margin);
+            pdf_add_bp(pdf, -form_margin);
+            pdf_add_bp(pdf, pdf->page_size.h + form_margin);
+            pdf_add_bp(pdf, pdf->page_size.v + form_margin);
+            pdf_end_array(pdf);
+        }
+        if (xform_type == 0 || xform_type == 2 || xform_type == 3) {
+            pdf_add_name(pdf, "Matrix");
+            pdf_begin_array(pdf);
+            pdf_add_int(pdf, 1);
+            pdf_add_int(pdf, 0);
+            pdf_add_int(pdf, 0);
+            pdf_add_int(pdf, 1);
+            pdf_add_int(pdf, 0);
+            pdf_add_int(pdf, 0);
+            pdf_end_array(pdf);
+        }
         pdf_dict_add_ref(pdf, "Resources", pdf->page_resources->last_resources);
     }
     /* Start stream of page/form contents */
diff --git a/source/texk/web2c/luatexdir/pdf/pdfglyph.w b/source/texk/web2c/luatexdir/pdf/pdfglyph.w
index 93096d025e5cefb38fcc8a9ca0d7b5de3fd7b94f..a10598289380f445f5fd42e96a8295e6ac20ad26 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfglyph.w
+++ b/source/texk/web2c/luatexdir/pdf/pdfglyph.w
@@ -22,13 +22,10 @@
 #include "ptexlib.h"
 #include "pdf/pdfpage.h"
 
-#define pdf2double(a) ((double) (a).m / ten_pow[(a).e])
-
 @ eternal constants
 
 @c
-#define one_bp ((double) 65536 * (double) 72.27 / 72)  /* number of sp per 1bp */
-#define e_tj 3                                         /* must be 3; movements in []TJ are in fontsize/$10^3$ units */
+#define e_tj 3 /* must be 3; movements in []TJ are in fontsize/$10^3$ units */
 
 @ @c
 static int64_t pdf_char_width(pdfstructure * p, internal_font_number f, int i)
@@ -58,7 +55,7 @@ static void setup_fontparameters(PDF pdf, internal_font_number f, int ex_glyph)
         u = font_units_per_em(f) / 1000.0;
     pdf->f_cur = f;
     p->f_pdf = pdf_set_font(pdf, f);
-    p->fs.m = i64round(font_size(f) / u / one_bp * ten_pow[p->fs.e]);
+    p->fs.m = i64round(font_size(f) / u / by_one_bp * ten_pow[p->fs.e]);
     slant = font_slant(f) / 1000.0;
     extend = font_extend(f) / 1000.0;
     expand = 1.0 + (ex_glyph/1) / 1000.0;
diff --git a/source/texk/web2c/luatexdir/pdf/pdflistout.w b/source/texk/web2c/luatexdir/pdf/pdflistout.w
index b6f3e6ff1a1c10354bc8b1edccd0395780f17323..8c5abad53029c9f20938b504cc4b41bfd1dc4373 100644
--- a/source/texk/web2c/luatexdir/pdf/pdflistout.w
+++ b/source/texk/web2c/luatexdir/pdf/pdflistout.w
@@ -310,7 +310,7 @@ void hlist_out(PDF pdf, halfword this_box, int rule_callback_id)
     int i;                      /* index to scan |pdf_link_stack| */
     int save_loc = 0;           /* DVI! \.{DVI} byte location upon entry */
     scaledpos save_dvi = { 0, 0 };      /* DVI! what |dvi| should pop to */
-    int synctex = int_par(synctex_code) ;
+    int synctex = synctex_par ;
 
     g_order = glue_order(this_box);
     g_sign = glue_sign(this_box);
@@ -764,7 +764,7 @@ void vlist_out(PDF pdf, halfword this_box, int rule_callback_id)
     scaled_whd rule;
     int save_loc = 0;              /* DVI byte location upon entry */
     scaledpos save_dvi = { 0, 0 }; /* DVI! what |dvi| should pop to */
-    int synctex = int_par(synctex_code) ;
+    int synctex = synctex_par ;
 
     g_order = (glue_ord) glue_order(this_box);
     g_sign = glue_sign(this_box);
diff --git a/source/texk/web2c/luatexdir/pdf/pdfobj.w b/source/texk/web2c/luatexdir/pdf/pdfobj.w
index 7dd510615950fc46ed9d2bcb965eeaba82048b75..e5ca09de624f238cc0ce3f9260c5eac2b2912097 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfobj.w
+++ b/source/texk/web2c/luatexdir/pdf/pdfobj.w
@@ -29,13 +29,21 @@ void pdf_write_obj(PDF pdf, int k)
     lstring data;
     const_lstring st;
     size_t li;                  /* index into |data.s| */
-    int saved_compress_level = pdf->compress_level;
+    int saved_compress_level ;
     int os_threshold = OBJSTM_ALWAYS;   /* gives compressed objects for \.{\\pdfvariable objcompresslevel} >= |OBJSTM_ALWAYS| */
     int l = 0;                          /* possibly a lua registry reference */
     int ll = 0;
     data.s = NULL;
-    if (obj_obj_pdfcompresslevel(pdf, k) > -1)  /* -1 = "unset" */
+    /* we can have an immediate object before we are initialized */
+    ensure_output_state(pdf, ST_HEADER_WRITTEN);
+    saved_compress_level = pdf->compress_level;
+    /* end of ugly hack */
+    if (obj_obj_pdfcompresslevel(pdf, k) > -1) { /* -1 = "unset" */
         pdf->compress_level = obj_obj_pdfcompresslevel(pdf, k);
+        if (pdf->compress_level == 0) {
+            pdf->objcompresslevel = 0;
+        }
+    }
     if (obj_obj_objstm_threshold(pdf, k) != OBJSTM_UNSET)
         os_threshold = obj_obj_objstm_threshold(pdf, k);
     if (obj_obj_is_stream(pdf, k)) {
@@ -183,21 +191,19 @@ void scan_obj(PDF pdf)
 }
 
 @ @c
-#define tail cur_list.tail_field
-
 void scan_refobj(PDF pdf)
 {
     scan_int();
     check_obj_type(pdf, obj_type_obj, cur_val);
     new_whatsit(pdf_refobj_node);
-    pdf_obj_objnum(tail) = cur_val;
+    pdf_obj_objnum(tail_par) = cur_val;
 }
 
 void scan_refobj_lua(PDF pdf, int k)
 {
     check_obj_type(pdf, obj_type_obj, k);
     new_whatsit(pdf_refobj_node);
-    pdf_obj_objnum(tail) = k;
+    pdf_obj_objnum(tail_par) = k;
 }
 
 @ @c
diff --git a/source/texk/web2c/luatexdir/pdf/pdfpage.w b/source/texk/web2c/luatexdir/pdf/pdfpage.w
index 90f63534d327943377eed5f13a92551238b16aab..f0782d2093c3839f86cd58420fbb1e03e9699c7e 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfpage.w
+++ b/source/texk/web2c/luatexdir/pdf/pdfpage.w
@@ -26,11 +26,6 @@
 #include <assert.h>
 #include <math.h>
 
-@ eternal constant: number of sp per 1bp
-
-@c
-#define one_bp ((double) 65536 * (double) 72.27 / 72)
-
 @ @c
 void init_pdf_pagecalculations(PDF pdf)
 {
@@ -66,7 +61,7 @@ void init_pdf_pagecalculations(PDF pdf)
     p->ishex = 0;
     p->need_tf = false;
     p->need_tm = false;
-    p->k1 = ten_pow[p->pdf.h.e] / one_bp;
+    p->k1 = ten_pow[p->pdf.h.e] / by_one_bp;
 }
 
 @ @c
diff --git a/source/texk/web2c/luatexdir/pdf/pdfshipout.w b/source/texk/web2c/luatexdir/pdf/pdfshipout.w
index 253f8dc420246fba22e18412afd80ea79e6924bf..8665f685e1f13845c1bdc81a62381b3b73a583ff 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfshipout.w
+++ b/source/texk/web2c/luatexdir/pdf/pdfshipout.w
@@ -22,20 +22,6 @@
 #include "ptexlib.h"
 
 @ @c
-#define count(A) eqtb[count_base+(A)].cint
-
-#define mag                int_par(mag_code)
-#define h_offset           dimen_par(h_offset_code)
-#define page_bottom_offset dimen_par(page_bottom_offset_code)
-#define page_height        dimen_par(page_height_code)
-#define page_left_offset   dimen_par(page_left_offset_code)
-#define page_right_offset  dimen_par(page_right_offset_code)
-#define page_top_offset    dimen_par(page_top_offset_code)
-#define page_width         dimen_par(page_width_code)
-#define tracing_output     int_par(tracing_output_code)
-#define tracing_stats      int_par(tracing_stats_code)
-#define v_offset           dimen_par(v_offset_code)
-
 scaledpos shipbox_refpos;
 
 @ |ship_out| is used to shipout a box to PDF or DVI mode. If |shipping_mode| is
@@ -61,16 +47,16 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
         Start sheet {\sl Sync\TeX} information record; we assume that |pdf_output| is
         properly set up.
     */
-    if (int_par(synctex_code)) {
+    if (synctex_par) {
         if (output_mode_used == OMODE_DVI) {
-            synctexsheet(mag);
+            synctexsheet(mag_par);
         } else {
             synctexsheet(1000);
         }
     }
     pre_callback_id = callback_defined(start_page_number_callback);
     post_callback_id = callback_defined(stop_page_number_callback);
-    if ((tracing_output > 0) && (pre_callback_id == 0)) {
+    if ((tracing_output_par > 0) && (pre_callback_id == 0)) {
         tprint_nl("");
         print_ln();
         tprint("Completed box being shipped out");
@@ -95,7 +81,7 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
             }
         }
     }
-    if ((tracing_output > 0) && shipping_mode == SHIPPING_PAGE) {
+    if ((tracing_output_par > 0) && shipping_mode == SHIPPING_PAGE) {
         print_char(']');
         update_terminal();
         begin_diagnostic();
@@ -103,7 +89,7 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
         end_diagnostic(true);
     }
     /* Ship box |p| out */
-    if (shipping_mode == SHIPPING_PAGE && box_dir(p) != page_direction)
+    if (shipping_mode == SHIPPING_PAGE && box_dir(p) != page_direction_par)
         normal_warning("backend","pagedir differs from bodydir, the output may be placed wrongly on the page");
     /*
         Update the values of |max_h| and |max_v|; but if the page is too large,
@@ -111,14 +97,14 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
         error messages are being ignored. Such pages are not output to the
         \.{dvi} file, since they may confuse the printing software.
     */
-    if ((height(p) > max_dimen) || (depth(p) > max_dimen) || (height(p) + depth(p) + v_offset > max_dimen) || (width(p) + h_offset > max_dimen)) {
+    if ((height(p) > max_dimen) || (depth(p) > max_dimen) || (height(p) + depth(p) + v_offset_par > max_dimen) || (width(p) + h_offset_par > max_dimen)) {
         const char *hlp[] = {
             "The page just created is more than 18 feet tall or",
             "more than 18 feet wide, so I suspect something went wrong.",
             NULL
         };
         tex_error("Huge page cannot be shipped out", hlp);
-        if (tracing_output <= 0) {
+        if (tracing_output_par <= 0) {
             begin_diagnostic();
             tprint_nl("The following box has been deleted:");
             show_box(p);
@@ -126,47 +112,47 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
         }
         goto DONE;
     }
-    if (height(p) + depth(p) + v_offset > max_v)
-        max_v = height(p) + depth(p) + v_offset;
-    if (width(p) + h_offset > max_h)
-        max_h = width(p) + h_offset;
+    if (height(p) + depth(p) + v_offset_par > max_v)
+        max_v = height(p) + depth(p) + v_offset_par;
+    if (width(p) + h_offset_par > max_h)
+        max_h = width(p) + h_offset_par;
     /* Calculate page dimensions and margins */
     if (global_shipping_mode == SHIPPING_PAGE) {
-        if (page_width > 0)
-            pdf->page_size.h = page_width;
+        if (page_width_par > 0)
+            pdf->page_size.h = page_width_par;
         else {
-            switch (page_direction) {
+            switch (page_direction_par) {
                 case dir_TLT:
-                    pdf->page_size.h = width(p) + 2 * page_left_offset;
+                    pdf->page_size.h = width(p) + 2 * page_left_offset_par;
                     break;
                 case dir_TRT:
-                    pdf->page_size.h = width(p) + 2 * page_right_offset;
+                    pdf->page_size.h = width(p) + 2 * page_right_offset_par;
                     break;
                 case dir_LTL:
-                    pdf->page_size.h = height(p) + depth(p) + 2 * page_left_offset;
+                    pdf->page_size.h = height(p) + depth(p) + 2 * page_left_offset_par;
                     break;
                 case dir_RTT:
-                    pdf->page_size.h = height(p) + depth(p) + 2 * page_right_offset;
+                    pdf->page_size.h = height(p) + depth(p) + 2 * page_right_offset_par;
                     break;
                 default:
-                    pdf->page_size.h = width(p) + 2 * page_left_offset;
+                    pdf->page_size.h = width(p) + 2 * page_left_offset_par;
                     normal_warning("pdf backend","bad page direction, assuming TLT, case 1");
             }
         }
-        if (page_height > 0)
-            pdf->page_size.v = page_height;
+        if (page_height_par > 0)
+            pdf->page_size.v = page_height_par;
         else {
-            switch (page_direction) {
+            switch (page_direction_par) {
                 case dir_TLT:
                 case dir_TRT:
-                    pdf->page_size.v = height(p) + depth(p) + 2 * page_top_offset;
+                    pdf->page_size.v = height(p) + depth(p) + 2 * page_top_offset_par;
                     break;
                 case dir_LTL:
                 case dir_RTT:
-                    pdf->page_size.v = width(p) + 2 * page_top_offset;
+                    pdf->page_size.v = width(p) + 2 * page_top_offset_par;
                     break;
                 default:
-                    pdf->page_size.v = height(p) + depth(p) + 2 * page_top_offset;
+                    pdf->page_size.v = height(p) + depth(p) + 2 * page_top_offset_par;
                     normal_warning("pdf backend","bad page direction, assuming TLT, case 2");
                 }
         }
@@ -193,27 +179,27 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
             Then shift |refpoint.pos| of the DVI origin depending on the
             |page_direction| within the upright (TLT) page coordinate system
         */
-        switch (page_direction) {
+        switch (page_direction_par) {
             case dir_TLT:
             case dir_LTL:
-                refpoint.pos.h += h_offset;
-                refpoint.pos.v -= v_offset;
+                refpoint.pos.h += h_offset_par;
+                refpoint.pos.v -= v_offset_par;
                 break;
             case dir_TRT:
             case dir_RTT:
-                refpoint.pos.h += pdf->page_size.h - page_right_offset - one_true_inch;
-                refpoint.pos.v -= v_offset;
+                refpoint.pos.h += pdf->page_size.h - page_right_offset_par - one_true_inch;
+                refpoint.pos.v -= v_offset_par;
                 break;
             default:
-                refpoint.pos.h += h_offset;
-                refpoint.pos.v -= v_offset;
+                refpoint.pos.h += h_offset_par;
+                refpoint.pos.v -= v_offset_par;
                 normal_warning("pdf backend","bad page direction, assuming TLT, case 3");
         }
         /*
             Then switch to page box coordinate system; do |height(p)| movement,
             to get the location of the box origin.
         */
-        pdf->posstruct->dir = page_direction;
+        pdf->posstruct->dir = page_direction_par;
         cur.h = 0;
         cur.v = height(p);
         synch_pos_with_cur(pdf->posstruct, &refpoint, cur);
@@ -297,13 +283,13 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
             normal_error("pdf backend", "unknown output mode");
     }
   DONE:
-    if ((tracing_output <= 0) && (post_callback_id == 0) && shipping_mode == SHIPPING_PAGE) {
+    if ((tracing_output_par <= 0) && (post_callback_id == 0) && shipping_mode == SHIPPING_PAGE) {
         print_char(']');
         update_terminal();
     }
     dead_cycles = 0;
     /* Flush the box from memory, showing statistics if requested */
-    if ((tracing_stats > 1) && (pre_callback_id == 0)) {
+    if ((tracing_stats_par > 1) && (pre_callback_id == 0)) {
         tprint_nl("Memory usage before: ");
         print_int(var_used);
         print_char('&');
@@ -311,7 +297,7 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
         print_char(';');
     }
     flush_node_list(p);
-    if ((tracing_stats > 1) && (post_callback_id == 0)) {
+    if ((tracing_stats_par > 1) && (post_callback_id == 0)) {
         tprint(" after: ");
         print_int(var_used);
         print_char('&');
@@ -321,7 +307,7 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode)
     if (shipping_mode == SHIPPING_PAGE && (post_callback_id > 0))
         (void) run_callback(post_callback_id, "->");
     /* Finish sheet {\sl Sync\TeX} information record */
-    if (int_par(synctex_code))
+    if (synctex_par)
         synctexteehs();
     global_shipping_mode = NOT_SHIPPING;
 }
diff --git a/source/texk/web2c/luatexdir/pdf/pdftables.h b/source/texk/web2c/luatexdir/pdf/pdftables.h
index 47dee7c694985a585e44dcdac321fd63a1a03d0c..d36f6e611a9d34ee09de8763fa65acdba95d3af3 100644
--- a/source/texk/web2c/luatexdir/pdf/pdftables.h
+++ b/source/texk/web2c/luatexdir/pdf/pdftables.h
@@ -99,6 +99,10 @@ depending on the object type; however it may be used as a counter as well.
 #  define inf_pk_dpi   72 /* min PK pixel density value from \.{texmf.cnf} */
 #  define sup_pk_dpi 8000 /* max PK pixel density value from \.{texmf.cnf} */
 
+#  define pdf2double(a) ((double) (a).m / ten_pow[(a).e])
+
+#  define by_one_bp ((double) 65536 * (double) 72.27 / 72)  /* number of sp per 1bp */
+
 extern int find_obj(PDF pdf, int t, int i, boolean byname);
 extern void check_obj_exists(PDF pdf, int objnum);
 extern void check_obj_type(PDF pdf, int t, int objnum);
diff --git a/source/texk/web2c/luatexdir/pdf/pdfthread.w b/source/texk/web2c/luatexdir/pdf/pdfthread.w
index b11e48c5fc028d9b9978bbd93655d131ade33408..6b3dd4b943292e8c23c260bb2e40cedca0b0a7cf 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfthread.w
+++ b/source/texk/web2c/luatexdir/pdf/pdfthread.w
@@ -21,10 +21,6 @@
 
 #include "ptexlib.h"
 
-@ @c
-#define page_width dimen_par(page_width_code)
-#define page_height dimen_par(page_height_code)
-
 @ Threads are handled in similar way as link annotations
 @c
 void append_bead(PDF pdf, halfword p)
@@ -168,8 +164,8 @@ void pdf_fix_thread(PDF pdf, int t)
     pdf_begin_array(pdf);
     pdf_add_int(pdf, 0);
     pdf_add_int(pdf, 0);
-    pdf_add_bp(pdf, page_width);
-    pdf_add_bp(pdf, page_height);
+    pdf_add_bp(pdf, page_width_par);
+    pdf_add_bp(pdf, page_height_par);
     pdf_end_array(pdf);
     pdf_end_dict(pdf);
     pdf_end_obj(pdf);
diff --git a/source/texk/web2c/luatexdir/pdf/pdfxform.h b/source/texk/web2c/luatexdir/pdf/pdfxform.h
index f7f6e54d68f025d81cf47b7b025468348a3c5377..64525d837ea2b24797b553fc74fd57c81ebeae35 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfxform.h
+++ b/source/texk/web2c/luatexdir/pdf/pdfxform.h
@@ -22,7 +22,7 @@
 #ifndef PDFXFORM_H
 #  define PDFXFORM_H
 
-#  define pdfmem_xform_size 8 /* size of memory in |pdf->mem| which |obj_data_ptr| holds */
+#  define pdfmem_xform_size 9 /* size of memory in |pdf->mem| which |obj_data_ptr| holds */
 
 #  define obj_xform_width(pdf,A)          pdf->mem[obj_data_ptr(pdf,A) + 0]
 #  define obj_xform_height(pdf,A)         pdf->mem[obj_data_ptr(pdf,A) + 1]
@@ -32,6 +32,7 @@
 #  define obj_xform_resources(pdf,A)      pdf->mem[obj_data_ptr(pdf,A) + 5] /* additional xform Resources */
 #  define obj_xform_attr_str(pdf,A)       pdf->mem[obj_data_ptr(pdf,A) + 6]
 #  define obj_xform_resources_str(pdf,A)  pdf->mem[obj_data_ptr(pdf,A) + 7]
+#  define obj_xform_type(pdf,A)           pdf->mem[obj_data_ptr(pdf,A) + 8]
 
 #  define set_pdf_xform_objnum(A,B)            pdf_xform_objnum(A)=B
 #  define set_obj_xform_width(pdf,A,B)         obj_xform_width(pdf,A)=B
@@ -42,6 +43,7 @@
 #  define set_obj_xform_resources(pdf,A,B)     obj_xform_resources(pdf,A)=B
 #  define set_obj_xform_attr_str(pdf,A,B)      obj_xform_attr_str(pdf,A)=B
 #  define set_obj_xform_resources_str(pdf,A,B) obj_xform_resources_str(pdf,A)=B
+#  define set_obj_xform_type(pdf,A,B)          obj_xform_type(pdf,A)=B
 
 extern int pdf_cur_form; /* the form being output */
 
diff --git a/source/texk/web2c/luatexdir/pdf/pdfxform.w b/source/texk/web2c/luatexdir/pdf/pdfxform.w
index 962acb0f031a9e7a3630143b476d56e204c8d921..4c83b024939bfbee2631e687d2a64223300b000a 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfxform.w
+++ b/source/texk/web2c/luatexdir/pdf/pdfxform.w
@@ -22,8 +22,6 @@
 #include "pdf/pdfpage.h"
 
 @ @c
-#define box(A) eqtb[box_base+(A)].hh.rh
-
 int pdf_cur_form;               /* the form being output */
 
 void pdf_place_form(PDF pdf, halfword p)
@@ -72,6 +70,12 @@ void scan_pdfxform(PDF pdf)
     pdf->xform_count++;
     k = pdf_create_obj(pdf, obj_type_xform, pdf->xform_count);
     set_obj_data_ptr(pdf, k, pdf_get_mem(pdf, pdfmem_xform_size));
+    if (scan_keyword("type")) {
+        scan_int();
+        set_obj_xform_type(pdf, k, cur_val);
+    } else {
+        set_obj_xform_type(pdf, k, 0);
+    }
     if (scan_keyword("attr")) {
         scan_toks(false, true);
         set_obj_xform_attr(pdf, k, def_ref);
@@ -99,8 +103,6 @@ void scan_pdfxform(PDF pdf)
 }
 
 @ @c
-#define tail          cur_list.tail_field
-
 void scan_pdfrefxform(PDF pdf)
 {
     scaled_whd alt_rule, dim, nat;
@@ -116,8 +118,8 @@ void scan_pdfrefxform(PDF pdf)
     } else {
         dim = nat;
     }
-    width(tail) = dim.wd;
-    height(tail) = dim.ht;
-    depth(tail) = dim.dp;
-    rule_index(tail) = cur_val;
+    width(tail_par) = dim.wd;
+    height(tail_par) = dim.ht;
+    depth(tail_par) = dim.dp;
+    rule_index(tail_par) = cur_val;
 }
diff --git a/source/texk/web2c/luatexdir/ptexlib.h b/source/texk/web2c/luatexdir/ptexlib.h
index a70bcfb2d9280f9f75fc83e719ee8feb3d345d96..e71efae65f823be010134272b7920504be7d3ff2 100644
--- a/source/texk/web2c/luatexdir/ptexlib.h
+++ b/source/texk/web2c/luatexdir/ptexlib.h
@@ -111,7 +111,7 @@ extern char **suffixlist;       /* in luainit.w */
         *p = 0;                                        \
 } while (0)
 
-#  define skip(p, c)   if (*p == c)  p++
+#  define skip_char(p, c)   if (*p == c)  p++
 
 #  define alloc_array(T, n, s) do {					\
 	if (T##_array == NULL) {					\
diff --git a/source/texk/web2c/luatexdir/tex/align.w b/source/texk/web2c/luatexdir/tex/align.w
index b5c5b71f1891e688ae7f2e5c92ebe5458d99b902..dd0ed10338e4eb68d02cb79cd870473415a93c41 100644
--- a/source/texk/web2c/luatexdir/tex/align.w
+++ b/source/texk/web2c/luatexdir/tex/align.w
@@ -31,16 +31,6 @@ void init_col(void);
 
 #define noDEBUG
 
-#define end_template_token (cs_token_flag+frozen_end_template)
-
-#define prev_depth      cur_list.prev_depth_field
-#define space_factor    cur_list.space_factor_field
-#define incompleat_noad cur_list.incompleat_noad_field
-
-#define every_cr          equiv(every_cr_loc)
-#define max_depth         dimen_par(max_depth_code)
-#define overfull_rule     dimen_par(overfull_rule_code)
-
 @ It's sort of a miracle whenever \.{\\halign} and \.{\\valign} work, because
 they cut across so many of the control structures of \TeX.
 
@@ -176,10 +166,12 @@ is necessary to store information about what to do when a template ends.
 This information is called the |extra_info| field.
 
 @c
-#define u_part(A) vlink((A)+depth_offset)       /* pointer to \<u_j> token list */
-#define v_part(A) vinfo((A)+depth_offset)       /* pointer to \<v_j> token list */
-#define span_ptr(A) vinfo((A)+1)        /* column spanning list */
-#define extra_info(A) vinfo((A)+list_offset)    /* info to remember during template */
+/* could be in texnodes.h, but documented here*/
+
+#define u_part(A)     vlink((A)+depth_offset) /* pointer to \<u_j> token list */
+#define v_part(A)     vinfo((A)+depth_offset) /* pointer to \<v_j> token list */
+#define span_ptr(A)   vinfo((A)+1)            /* column spanning list */
+#define extra_info(A) vinfo((A)+list_offset)  /* info to remember during template */
 
 @ Alignments can occur within alignments, so a small stack is used to access
 the alignrecord information. At each level we have a |preamble| pointer,
@@ -200,6 +192,8 @@ when they have to be pushed down, they are stored in 6-word nodes, and
 |align_ptr| points to the topmost such node.
 
 @c
+/* could be in texnodes.h but documented here*/
+
 #define preamble vlink(align_head)      /* the current preamble list */
 
 pointer cur_align = null;       /* current position in preamble list */
@@ -300,7 +294,7 @@ static void get_preamble_token(void)
         && (cur_chr == glue_base + tab_skip_code)) {
         scan_optional_equals();
         scan_glue(glue_val_level);
-        if (int_par(global_defs_code) > 0)
+        if (global_defs_par > 0)
             geq_define(glue_base + tab_skip_code, glue_ref_cmd, cur_val);
         else
             eq_define(glue_base + tab_skip_code, glue_ref_cmd, cur_val);
@@ -331,7 +325,7 @@ void init_align(void)
 
     if ((cur_list.mode_field == mmode)
         && ((cur_list.tail_field != cur_list.head_field)
-            || (incompleat_noad != null))) {
+            || (incompleat_noad_par != null))) {
         const char *hlp[] =
             { "Displays can use special alignments (like \\eqalignno)",
             "only if nothing but the alignment itself is between $$'s.",
@@ -348,7 +342,7 @@ void init_align(void)
        correct baseline calculations. */
     if (cur_list.mode_field == mmode) {
         cur_list.mode_field = -vmode;
-        prev_depth = nest[nest_ptr - 2].prev_depth_field;
+        prev_depth_par = nest[nest_ptr - 2].prev_depth_field;
     } else if (cur_list.mode_field > 0) {
         cur_list.mode_field = -(cur_list.mode_field);
     }
@@ -444,8 +438,8 @@ void init_align(void)
     scanner_status = normal;
 
     new_save_level(align_group);
-    if (every_cr != null)
-        begin_token_list(every_cr, every_cr_text);
+    if (every_cr_par != null)
+        begin_token_list(every_cr_par, every_cr_text);
     align_peek();               /* look for \.{\\noalign} or \.{\\omit} */
 }
 
@@ -493,9 +487,9 @@ static void init_span(pointer p)
 {
     push_nest();
     if (cur_list.mode_field == -hmode) {
-        space_factor = 1000;
+        space_factor_par = 1000;
     } else {
-        prev_depth = ignore_depth;
+        prev_depth_par = ignore_depth;
         normal_paragraph();
     }
     cur_span = p;
@@ -514,9 +508,9 @@ void init_row(void)
     push_nest();
     cur_list.mode_field = (-hmode - vmode) - cur_list.mode_field;
     if (cur_list.mode_field == -hmode)
-        space_factor = 0;
+        space_factor_par = 0;
     else
-        prev_depth = 0;
+        prev_depth_par = 0;
     tail_append(new_glue(preamble));
     subtype(cur_list.tail_field) = tab_skip_code + 1;
     cur_align = vlink(preamble);
@@ -780,16 +774,16 @@ void fin_row(void)
             append_list(cur_head, cur_tail);
     } else {
         p = filtered_vpackage(vlink(cur_list.head_field),
-            0, additional, max_depth, fin_row_group, -1, 0, 0);
+            0, additional, max_depth_par, fin_row_group, -1, 0, 0);
         pop_nest();
         vlink(cur_list.tail_field) = p;
         cur_list.tail_field = p;
-        space_factor = 1000;
+        space_factor_par = 1000;
     }
     type(p) = unset_node;
     glue_stretch(p) = 0;
-    if (every_cr != null)
-        begin_token_list(every_cr, every_cr_text);
+    if (every_cr_par != null)
+        begin_token_list(every_cr_par, every_cr_text);
     align_peek();
     /* note that |glue_shrink(p)=0| since |glue_shrink==shift_amount| */
 }
@@ -816,7 +810,7 @@ void fin_align(void)
         confusion("align0");
     unsave();                   /* that |align_group| was for the whole alignment */
     if (nest[nest_ptr - 1].mode_field == mmode)
-        o = display_indent;
+        o = display_indent_par;
     else
         o = 0;
     /* Go through the preamble list, determining the column widths and
@@ -916,10 +910,10 @@ value is changed to zero and so is the next tabskip.
     decr(save_ptr);
     pack_begin_line = -cur_list.ml_field;
     if (cur_list.mode_field == -vmode) {
-        rule_save = overfull_rule;
-        overfull_rule = 0;      /* prevent rule from being packaged */
+        rule_save = overfull_rule_par;
+        overfull_rule_par = 0;      /* prevent rule from being packaged */
         p = hpack(preamble, saved_value(0), saved_level(0), -1);
-        overfull_rule = rule_save;
+        overfull_rule_par = rule_save;
     } else {
         q = vlink(preamble);
         do {
@@ -928,7 +922,7 @@ value is changed to zero and so is the next tabskip.
             q = vlink(vlink(q));
         } while (q != null);
         p = filtered_vpackage(preamble,
-            saved_value(0), saved_level(0), max_depth, preamble_group, -1, 0, 0);
+            saved_value(0), saved_level(0), max_depth_par, preamble_group, -1, 0, 0);
         q = vlink(preamble);
         do {
             width(q) = height(q);
@@ -1119,14 +1113,14 @@ value is changed to zero and so is the next tabskip.
        we will need to insert glue before and after the display; that part of the
        program will be deferred until we're more familiar with such operations.)
      */
-    pd = cur_list.prev_depth_field;
+    pd = prev_depth_par;
     p = vlink(cur_list.head_field);
     q = cur_list.tail_field;
     pop_nest();
     if (cur_list.mode_field == mmode) {
         finish_display_alignment(p, q, pd);
     } else {
-	cur_list.prev_depth_field = pd; /* aux:=aux_save; */
+        prev_depth_par = pd; /* aux:=aux_save; */
         vlink(cur_list.tail_field) = p;
         if (p != null)
             cur_list.tail_field = q;
diff --git a/source/texk/web2c/luatexdir/tex/buildpage.w b/source/texk/web2c/luatexdir/tex/buildpage.w
index 104566f790b793275b035afbb5d4e8b8b2a6182c..c45d9cb7d7eac754a4985c3b2e395c6c845f9c96 100644
--- a/source/texk/web2c/luatexdir/tex/buildpage.w
+++ b/source/texk/web2c/luatexdir/tex/buildpage.w
@@ -22,29 +22,9 @@
 #include "ptexlib.h"
 
 @ @c
-#define box(A) eqtb[box_base+(A)].hh.rh
-#define count(A) eqtb[count_base+(A)].hh.rh
-#undef skip
-#define skip(A) eqtb[skip_base+(A)].hh.rh
-#define dimen(A) eqtb[scaled_base+(A)].hh.rh
-
-#define vbadness int_par(vbadness_code)
-#define max_dead_cycles int_par(max_dead_cycles_code)
-#define output_box int_par(output_box_code)
-#define holding_inserts int_par(holding_inserts_code)
-
-#define vsize dimen_par(vsize_code)
-#define vfuzz dimen_par(vfuzz_code)
-#define max_depth dimen_par(max_depth_code)
-
-#define output_routine equiv(output_routine_loc)
-#define split_top_skip glue_par(split_top_skip_code)
-
-#define prev_depth cur_list.prev_depth_field
-#define mode_line cur_list.ml_field
-#define mode cur_list.mode_field
-#define tail cur_list.tail_field
-#define head cur_list.head_field
+#define mode mode_par
+#define head head_par
+#define tail tail_par
 
 @ When \TeX\ appends new material to its main vlist in vertical mode, it uses
 a method something like |vsplit| to decide where a page ends, except that
@@ -221,12 +201,12 @@ from |empty| to |inserts_only| or |box_there|.
 void freeze_page_specs(int s)
 {
     page_contents = s;
-    page_goal = vsize;
-    page_max_depth = max_depth;
+    page_goal = vsize_par;
+    page_max_depth = max_depth_par;
     page_depth = 0;
     do_all_six(set_page_so_far_zero);
     least_page_cost = awful_bad;
-    if (int_par(tracing_pages_code) > 0) {
+    if (tracing_pages_par > 0) {
         begin_diagnostic();
         tprint_nl("%% goal height=");
         print_scaled(page_goal);
@@ -360,7 +340,7 @@ void build_page(void)
                 else
                     page_contents = box_there;
                 q = new_skip_param(top_skip_code);
-                if ((type(p) == hlist_node) && is_mirrored(body_direction)) {
+                if ((type(p) == hlist_node) && is_mirrored(body_direction_par)) {
                     if (width(q) > depth(p))
                         width(q) = width(q) - depth(p);
                     else
@@ -378,7 +358,7 @@ void build_page(void)
             } else {
                 /* Prepare to move a box or rule node to the current page,
                    then |goto contribute| */
-                if ((type(p) == hlist_node) && is_mirrored(body_direction)) {
+                if ((type(p) == hlist_node) && is_mirrored(body_direction_par)) {
                     page_total = page_total + page_depth + depth(p);
                     page_depth = height(p);
                 } else {
@@ -510,7 +490,7 @@ void build_page(void)
                         w = dimen(n) - height(r);
                     q = vert_break(ins_ptr(p), w, depth(p));
                     height(r) = height(r) + best_height_plus_depth;
-                    if (int_par(tracing_pages_code) > 0) {
+                    if (tracing_pages_par > 0) {
                         /* Display the insertion split cost */
                         begin_diagnostic();
                         tprint_nl("% split");
@@ -582,7 +562,7 @@ void build_page(void)
             }
             if (insert_penalties >= 10000)
                 c = awful_bad;
-            if (int_par(tracing_pages_code) > 0) {
+            if (tracing_pages_par > 0) {
                 /* Display the page break cost */
                 begin_diagnostic();
                 tprint_nl("%");
@@ -670,7 +650,7 @@ void build_page(void)
         /* Recycle node |p| */
         try_couple_nodes(contrib_head,vlink(p));
         vlink(p) = null;
-        if (int_par(saving_vdiscards_code) > 0) {
+        if (saving_vdiscards_par > 0) {
             if (page_disc == null) {
                 page_disc = p;
             } else {
@@ -746,18 +726,18 @@ void fire_up(halfword c)
     if (c == best_page_break)
         best_page_break = null; /* |c| not yet linked in */
     /* Ensure that box |output_box| is empty before output */
-    if (box(output_box) != null) {
+    if (box(output_box_par) != null) {
         print_err("\\box");
-        print_int(output_box);
+        print_int(output_box_par);
         tprint(" is not void");
         help2("You shouldn't use \\box\\outputbox except in \\output routines.",
               "Proceed, and I'll discard its present contents.");
-        box_error(output_box);
+        box_error(output_box_par);
     }
 
     insert_penalties = 0;       /* this will count the number of insertions held over */
-    save_split_top_skip = split_top_skip;
-    if (holding_inserts <= 0) {
+    save_split_top_skip = split_top_skip_par;
+    if (holding_inserts_par <= 0) {
         /* Prepare all the boxes involved in insertions to act as queues */
         /* If many insertions are supposed to go into the same box, we want to know
            the position of the last node in that box, so that we don't need to waste time
@@ -787,7 +767,7 @@ void fire_up(halfword c)
     p = vlink(prev_p);
     while (p != best_page_break) {
         if (type(p) == ins_node) {
-            if (holding_inserts <= 0) {
+            if (holding_inserts_par <= 0) {
                 /* Either insert the material specified by node |p| into the
                    appropriate box, or hold it for the next page;
                    also delete node |p| from the current page */
@@ -814,7 +794,7 @@ void fire_up(halfword c)
                                 while (vlink(s) != broken_ptr(r))
                                     s = vlink(s);
                                 vlink(s) = null;
-                                split_top_skip = split_top_ptr(p);
+                                split_top_skip_par = split_top_ptr(p);
                                 ins_ptr(p) =
                                     prune_page_top(broken_ptr(r), false);
                                 if (ins_ptr(p) != null) {
@@ -831,7 +811,7 @@ void fire_up(halfword c)
                         t = list_ptr(box(n));
                         list_ptr(box(n)) = null;
                         flush_node(box(n));
-                        box(n) = vpack(t, 0, additional, body_direction);
+                        box(n) = vpack(t, 0, additional, body_direction_par);
 
                     } else {
                         while (vlink(s) != null)
@@ -869,7 +849,7 @@ void fire_up(halfword c)
         prev_p = p;
         p = vlink(prev_p);
     }
-    split_top_skip = save_split_top_skip;
+    split_top_skip_par = save_split_top_skip;
     /* Break the current page at node |p|, put it in box~|output_box|,
        and put the remaining nodes on the contribution list */
     /* When the following code is executed, the current page runs from node
@@ -891,14 +871,14 @@ void fire_up(halfword c)
         couple_nodes(contrib_head, p);
         vlink(prev_p) = null;
     }
-    save_vbadness = vbadness;
-    vbadness = inf_bad;
-    save_vfuzz = vfuzz;
-    vfuzz = max_dimen;          /* inhibit error messages */
-    box(output_box) = filtered_vpackage(vlink(page_head),
-        best_size, exactly, page_max_depth, output_group, body_direction, 0, 0);
-    vbadness = save_vbadness;
-    vfuzz = save_vfuzz;
+    save_vbadness = vbadness_par;
+    vbadness_par = inf_bad;
+    save_vfuzz = vfuzz_par;
+    vfuzz_par = max_dimen;          /* inhibit error messages */
+    box(output_box_par) = filtered_vpackage(vlink(page_head),
+        best_size, exactly, page_max_depth, output_group, body_direction_par, 0, 0);
+    vbadness_par = save_vbadness;
+    vfuzz_par = save_vfuzz;
     if (last_glue != max_halfword)
         flush_node(last_glue);
     /* Start a new current page */
@@ -911,7 +891,7 @@ void fire_up(halfword c)
     /* Delete the page-insertion nodes */
     r = vlink(page_ins_head);
     while (r != page_ins_head) {
-	    /* todo: couple */ 
+	    /* todo: couple */
         q = vlink(r);
         flush_node(r);
         r = q;
@@ -924,8 +904,8 @@ void fire_up(halfword c)
             add_token_ref(top_mark(i));
         }
     }
-    if (output_routine != null) {
-        if (dead_cycles >= max_dead_cycles) {
+    if (output_routine_par != null) {
+        if (dead_cycles >= max_dead_cycles_par) {
             /* Explain that too many dead cycles have occurred in a row */
             print_err("Output loop---");
             print_int(dead_cycles);
@@ -941,9 +921,9 @@ void fire_up(halfword c)
             incr(dead_cycles);
             push_nest();
             mode = -vmode;
-            prev_depth = ignore_depth;
-            mode_line = -line;
-            begin_token_list(output_routine, output_text);
+            prev_depth_par = ignore_depth;
+            mode_line_par = -line;
+            begin_token_list(output_routine_par, output_text);
             new_save_level(output_group);
             normal_paragraph();
             scan_left_brace();
@@ -967,8 +947,8 @@ void fire_up(halfword c)
     }
     flush_node_list(page_disc);
     page_disc = null;
-    ship_out(static_pdf, box(output_box), SHIPPING_PAGE);
-    box(output_box) = null;
+    ship_out(static_pdf, box(output_box_par), SHIPPING_PAGE);
+    box(output_box_par) = null;
 }
 
 @ When the user's output routine finishes, it has constructed a vlist
@@ -996,13 +976,13 @@ void resume_after_output(void)
     output_active = false;
     insert_penalties = 0;
     /* Ensure that box |output_box| is empty after output */
-    if (box(output_box) != null) {
+    if (box(output_box_par) != null) {
         print_err("Output routine didn't use all of \\box");
-        print_int(output_box);
+        print_int(output_box_par);
         help3("Your \\output commands should empty \\box\\outputbox,",
               "e.g., by saying `\\shipout\\box\\outputbox'.",
               "Proceed; I'll discard its present contents.");
-        box_error(output_box);
+        box_error(output_box_par);
     }
 
     if (tail != head) {         /* current list goes after heldover insertions */
diff --git a/source/texk/web2c/luatexdir/tex/commands.h b/source/texk/web2c/luatexdir/tex/commands.h
index edaeb72fe28aae15c0604f409a37634b492d3f10..fc61ffd46c88b92a37e6be6122de0b22a2ae1bed 100644
--- a/source/texk/web2c/luatexdir/tex/commands.h
+++ b/source/texk/web2c/luatexdir/tex/commands.h
@@ -161,6 +161,7 @@ typedef enum {
     assign_mu_glue_cmd,                   /* user-defined muglue ( \.{\\thinmuskip}, etc.~) */
     assign_font_dimen_cmd,                /* user-defined font dimension ( \.{\\fontdimen} ) */
     assign_font_int_cmd,                  /* user-defined font integer ( \.{\\hyphenchar}, \.{\\skewchar} ) */
+    assign_hang_indent_cmd,
     set_aux_cmd,                          /* specify state info ( \.{\\spacefactor}, \.{\\prevdepth} ) */
     set_prev_graf_cmd,                    /* specify state info ( \.{\\prevgraf} ) */
     set_page_dimen_cmd,                   /* specify state info ( \.{\\pagegoal}, etc.~) */
@@ -326,11 +327,14 @@ typedef enum {
     expand_font_code,
 } normal_codes;
 
-#  define lp_code_base 2
-#  define rp_code_base 3
-#  define ef_code_base 4
-#  define tag_code 5
-#  define no_lig_code 6
+typedef enum {
+    lp_code_base = 2,
+    rp_code_base = 3,
+    ef_code_base = 4,
+    tag_code     = 5,
+    no_lig_code  = 6,
+    gp_code_base = 7
+} font_codes ;
 
 #  define immediate_code 4      /* command modifier for \.{\\immediate} */
 
diff --git a/source/texk/web2c/luatexdir/tex/commands.w b/source/texk/web2c/luatexdir/tex/commands.w
index ece74a5406b48d76f649351e59ecef56fc4bb3dd..882116435339e4a7b3af50402819b81eddee5a86 100644
--- a/source/texk/web2c/luatexdir/tex/commands.w
+++ b/source/texk/web2c/luatexdir/tex/commands.w
@@ -689,6 +689,7 @@ void initialize_commands(void)
     primitive_luatex("pardir", assign_dir_cmd, int_base + par_direction_code, dir_base);
     primitive_luatex("textdir", assign_dir_cmd, int_base + text_direction_code, dir_base);
     primitive_luatex("mathdir", assign_dir_cmd, int_base + math_direction_code, dir_base);
+    primitive_luatex("linedir", assign_dir_cmd, int_base + line_direction_code, dir_base);
     primitive_luatex("pageleftoffset", assign_dimen_cmd, dimen_base + page_left_offset_code, dimen_base);
     primitive_luatex("pagetopoffset", assign_dimen_cmd, dimen_base + page_top_offset_code, dimen_base);
     primitive_luatex("pagerightoffset", assign_dimen_cmd, dimen_base + page_right_offset_code, dimen_base);
@@ -767,6 +768,9 @@ void initialize_etex_commands(void)
     primitive_etex("parshapeindent", last_item_cmd, par_shape_indent_code, 0);
     primitive_etex("parshapedimen", last_item_cmd, par_shape_dimen_code, 0);
 
+    primitive_luatex("shapemode", assign_int_cmd, int_base + shape_mode_code, int_base);
+    primitive_luatex("hyphenationbounds", assign_int_cmd, int_base + hyphenation_bounds_code, int_base);
+
     primitive_etex("showgroups", xray_cmd, show_groups, 0);
 
     /*
diff --git a/source/texk/web2c/luatexdir/tex/conditional.w b/source/texk/web2c/luatexdir/tex/conditional.w
index fa4e73b49cb024fc844c515b31b39f683a5bd13b..268786add7548c722c87d3fdf3c7ab0dff537301 100644
--- a/source/texk/web2c/luatexdir/tex/conditional.w
+++ b/source/texk/web2c/luatexdir/tex/conditional.w
@@ -21,9 +21,6 @@
 
 #include "ptexlib.h"
 
-@ @c
-#define box(A) eqtb[box_base+(A)].hh.rh
-
 @* We consider now the way \TeX\ handles various kinds of \.{\\if} commands.
 
 @ Conditions can be inside conditions, and this nesting has a stack
@@ -79,7 +76,7 @@ void pass_text(void)
         }
     }
     scanner_status = save_scanner_status;
-    if (int_par(tracing_ifs_code) > 0)
+    if (tracing_ifs_par > 0)
         show_cur_cmd_chr();
 }
 
@@ -163,7 +160,7 @@ static boolean test_for_cs(void)
     }
     if (cur_cmd != end_cs_name_cmd) {
         last_tested_cs = null_cs;
-        if (int_par(suppress_ifcsname_error_code)) {
+        if (suppress_ifcsname_error_par) {
             do {
                 get_x_token();
             } while (cur_cmd != end_cs_name_cmd);
@@ -241,7 +238,7 @@ void conditional(void)
     halfword save_cond_ptr;     /*|cond_ptr| corresponding to this conditional */
     int this_if;                /*type of this conditional */
     boolean is_unless;          /*was this if preceded by `\.{\\unless}' ? */
-    if ((int_par(tracing_ifs_code) > 0) && (int_par(tracing_commands_code) <= 1))
+    if ((tracing_ifs_par > 0) && (tracing_commands_par <= 1))
         show_cur_cmd_chr();
     push_condition_stack();
     save_cond_ptr = cond_ptr;
@@ -441,7 +438,7 @@ void conditional(void)
             scan_int();
             /* |n| is the number of cases to pass */
             n = cur_val;
-            if (int_par(tracing_commands_code) > 1) {
+            if (tracing_commands_par > 1) {
                 begin_diagnostic();
                 tprint("{case ");
                 print_int(n);
@@ -508,7 +505,7 @@ void conditional(void)
     }
     if (is_unless)
         b = !b;
-    if (int_par(tracing_commands_code) > 1) {
+    if (tracing_commands_par > 1) {
         /* Display the value of |b| */
         begin_diagnostic();
         if (b)
diff --git a/source/texk/web2c/luatexdir/tex/dumpdata.w b/source/texk/web2c/luatexdir/tex/dumpdata.w
index 993ad8a16c02b30d236c9f5b7a865ff151e961f0..ae7695843817e4b4bac7f453bd4234343185b043 100644
--- a/source/texk/web2c/luatexdir/tex/dumpdata.w
+++ b/source/texk/web2c/luatexdir/tex/dumpdata.w
@@ -19,15 +19,11 @@
 
 @ @c
 
-
 #include "ptexlib.h"
 
-#define font_id_text(A) cs_text(font_id_base+(A))
-#define prev_depth cur_list.prev_depth_field
-
 /* we start with 907: the sum of the values of the bytes of "don knuth" */
 
-#define FORMAT_ID (907+15)
+#define FORMAT_ID (907+17)
 #if ((FORMAT_ID>=0) && (FORMAT_ID<=256))
 #error Wrong value for FORMAT_ID.
 #endif
@@ -91,11 +87,11 @@ void store_fmt_file(void)
     tprint(" (format=");
     print(job_name);
     print_char(' ');
-    print_int(int_par(year_code));
+    print_int(year_par);
     print_char('.');
-    print_int(int_par(month_code));
+    print_int(month_par);
     print_char('.');
-    print_int(int_par(day_code));
+    print_int(day_par);
     print_char(')');
     str_room(2);
     format_ident = make_string();
@@ -308,7 +304,7 @@ void store_fmt_file(void)
     dump_int(69069);
     /* We have already printed a lot of statistics, so we set |tracing_stats:=0|
        to prevent them from appearing again. */
-    int_par(tracing_stats_code) = 0;
+    tracing_stats_par = 0;
 
     /* Dump the lua bytecodes */
     dump_luac_registers();
@@ -520,7 +516,7 @@ boolean load_fmt_file(const char *fmtname)
     /* Undump the lua bytecodes */
     undump_luac_registers();
 
-    prev_depth = ignore_depth;
+    prev_depth_par = ignore_depth;
     return true;                /* it worked! */
   BAD_FMT:
     wake_up_terminal();
diff --git a/source/texk/web2c/luatexdir/tex/equivalents.h b/source/texk/web2c/luatexdir/tex/equivalents.h
index 66e9fdcaeeed4dae3c7970ad8b9c3afa7113433e..caebcceb0217cf45643c32757cae037fe2a10bd6 100644
--- a/source/texk/web2c/luatexdir/tex/equivalents.h
+++ b/source/texk/web2c/luatexdir/tex/equivalents.h
@@ -279,23 +279,26 @@ the |number_regs| \.{\\dimen} registers.
 #  define math_display_skip_mode_code 88
 #  define math_scripts_mode_code 89
 #  define synctex_code 90                                               /* is synctex file generation enabled ?  */
-#  define first_valid_language_code 91
+#  define shape_mode_code 91
+#  define first_valid_language_code 92
+#  define hyphenation_bounds_code 93
 
-#  define math_option_code 92
+#  define math_option_code 94
 
-#  define mathoption_int_base (int_base+93)
-#  define mathoption_int_last (int_base+99)
+#  define mathoption_int_base (int_base+95)                             /* one reserve */
+#  define mathoption_int_last (int_base+100)
 
-#  define backend_int_base (int_base+100)
-#  define backend_int_last (int_base+124)
+#  define backend_int_base (int_base+101)
+#  define backend_int_last (int_base+125)
 
-#  define tex_int_pars (125)                                            /* total number of integer parameters */
+#  define tex_int_pars (126)                                            /* total number of integer parameters */
 
 #  define page_direction_code (tex_int_pars)
 #  define body_direction_code (tex_int_pars+1)
 #  define par_direction_code  (tex_int_pars+2)
 #  define text_direction_code (tex_int_pars+3)
 #  define math_direction_code (tex_int_pars+4)
+#  define line_direction_code (tex_int_pars+5)                          /* gets remapped so is no real register */
 
 #  define int_pars (tex_int_pars+5)                                     /* total number of integer parameters */
 
@@ -533,26 +536,248 @@ extern void show_eqtb(halfword n);
 
 extern halfword last_cs_name;
 
-/* more will move here */
-
-#define space_skip         glue_par(space_skip_code)
-#define xspace_skip        glue_par(xspace_skip_code)
-#define math_skip          glue_par(math_skip_code)
+/*
+    The *_par macros expand to the variables that are (in most cases) also accessible
+    at the users end. Most are registers but some are in the (stack) lists.
 
-#define pre_display_size   dimen_par(pre_display_size_code)
-#define display_width      dimen_par(display_width_code)
-#define display_indent     dimen_par(display_indent_code)
-#define math_surround      dimen_par(math_surround_code)
+    More *_par will move here : there is no real need for thse macros but because there
+    were already a bunch and because they were defined all over the place we moved them
+    here.
 
-#define display_skip_mode  int_par(math_display_skip_mode_code)
-#define math_eqno_gap_step int_par(math_eqno_gap_step_code)
+*/
 
-#define body_direction     int_par(body_direction_code)
-#define page_direction     int_par(page_direction_code)
-#define par_direction      int_par(par_direction_code)
-#define text_direction     int_par(text_direction_code)
-#define math_direction     int_par(math_direction_code)
+#define space_skip_par                     glue_par(space_skip_code)
+#define xspace_skip_par                    glue_par(xspace_skip_code)
+#define math_skip_par                      glue_par(math_skip_code)
+
+#define pre_display_size_par               dimen_par(pre_display_size_code)
+#define display_width_par                  dimen_par(display_width_code)
+#define display_indent_par                 dimen_par(display_indent_code)
+#define math_surround_par                  dimen_par(math_surround_code)
+
+#define display_skip_mode_par              int_par(math_display_skip_mode_code)
+#define math_eqno_gap_step_par             int_par(math_eqno_gap_step_code)
+
+#define body_direction_par                 int_par(body_direction_code)
+#define page_direction_par                 int_par(page_direction_code)
+#define par_direction_par                  int_par(par_direction_code)
+#define text_direction_par                 int_par(text_direction_code)
+#define math_direction_par                 int_par(math_direction_code)
+
+#define shape_mode_par                     int_par(shape_mode_code)
+#define hyphenation_bounds_par             int_par(hyphenation_bounds_code)
+#define first_valid_language_par           int_par(first_valid_language_code)
+
+#define hsize_par                          dimen_par(hsize_code)
+#define vsize_par                          dimen_par(vsize_code)
+#define hfuzz_par                          dimen_par(hfuzz_code)
+#define vfuzz_par                          dimen_par(vfuzz_code)
+#define hbadness_par                       int_par(hbadness_code)
+#define vbadness_par                       int_par(vbadness_code)
+
+#define baseline_skip_par                  glue_par(baseline_skip_code)
+#define par_indent_par                     dimen_par(par_indent_code)
+#define hang_indent_par                    dimen_par(hang_indent_code)
+#define hang_after_par                     int_par(hang_after_code)
+#define left_skip_par                      glue_par(left_skip_code)
+#define right_skip_par                     glue_par(right_skip_code)
+
+#define emergency_stretch_par              glue_par(emergency_stretch_code)
+#define pretolerance_par                   int_par(pretolerance_code)
+#define tolerance_par                      int_par(tolerance_code)
+#define looseness_par                      int_par(looseness_code)
+#define adjust_spacing_par                 int_par(adjust_spacing_code)
+#define adj_demerits_par                   int_par(adj_demerits_code)
+#define protrude_chars_par                 int_par(protrude_chars_code)
+#define line_penalty_par                   int_par(line_penalty_code)
+#define last_line_fit_par                  int_par(last_line_fit_code)
+#define double_hyphen_demerits_par         int_par(double_hyphen_demerits_code)
+#define final_hyphen_demerits_par          int_par(final_hyphen_demerits_code)
+#define inter_line_penalty_par             int_par(inter_line_penalty_code)
+#define club_penalty_par                   int_par(club_penalty_code)
+#define broken_penalty_par                 int_par(broken_penalty_code)
+#define display_widow_penalty_par          int_par(display_widow_penalty_code)
+#define widow_penalty_par                  int_par(widow_penalty_code)
+#define line_skip_limit_par                dimen_par(line_skip_limit_code)
+
+#define delimiter_shortfall_par            dimen_par(delimiter_shortfall_code)
+#define null_delimiter_space_par           dimen_par(null_delimiter_space_code)
+#define script_space_par                   dimen_par(script_space_code)
+#define max_depth_par                      dimen_par(max_depth_code)
+#define box_max_depth_par                  dimen_par(box_max_depth_code)
+#define split_max_depth_par                dimen_par(split_max_depth_code)
+#define overfull_rule_par                  dimen_par(overfull_rule_code)
+#define box_max_depth_par                  dimen_par(box_max_depth_code)
+#define top_skip_par                       glue_par(top_skip_code)
+#define split_top_skip_par                 glue_par(split_top_skip_code)
+
+#define cur_fam_par                        int_par(cur_fam_code)
+#define pre_display_direction_par          int_par(pre_display_direction_code)
+#define pre_display_penalty_par            int_par(pre_display_penalty_code)
+#define post_display_penalty_par           int_par(post_display_penalty_code)
+
+#define cur_fam_par_in_range               ((cur_fam_par>=0)&&(cur_fam_par<256))
+
+#define local_inter_line_penalty_par       int_par(local_inter_line_penalty_code)
+#define local_broken_penalty_par           int_par(local_broken_penalty_code)
+#define local_left_box_par                 equiv(local_left_box_base)
+#define local_right_box_par                equiv(local_right_box_base)
+
+#define end_line_char_par                  int_par(end_line_char_code)
+#define new_line_char_par                  int_par(new_line_char_code)
+#define escape_char_par                    int_par(escape_char_code)
+
+#define end_line_char_inactive             ((end_line_char_par < 0) || (end_line_char_par > 127))
+
+#define delimiter_factor_par               int_par(delimiter_factor_code)
+#define bin_op_penalty_par                 int_par(bin_op_penalty_code)
+#define rel_penalty_par                    int_par(rel_penalty_code)
+#define null_delimiter_space_par           dimen_par(null_delimiter_space_code)
+#define disable_lig_par                    int_par(disable_lig_code)
+#define disable_kern_par                   int_par(disable_kern_code)
+#define disable_space_par                  int_par(disable_space_code)
+#define scripts_mode_par                   int_par(math_scripts_mode_code)
+
+#define thin_mu_skip_par                   glue_par(thin_mu_skip_code)
+#define med_mu_skip_par                    glue_par(med_mu_skip_code)
+#define thick_mu_skip_par                  glue_par(thick_mu_skip_code)
+
+#define every_math_par                     equiv(every_math_loc)
+#define every_display_par                  equiv(every_display_loc)
+#define every_cr_par                       equiv(every_cr_loc)
+#define every_hbox_par                     equiv(every_hbox_loc)
+#define every_vbox_par                     equiv(every_vbox_loc)
+#define every_eof_par                      equiv(every_eof_loc)
+#define every_par_par                      equiv(every_par_loc)
+#define err_help_par                       equiv(err_help_loc)
+
+#define no_local_whatsits_par              int_par(no_local_whatsits_code)
+#define no_local_dirs_par                  int_par(no_local_dirs_code)
+
+#define prev_depth_par                     cur_list.prev_depth_field
+#define prev_graf_par                      cur_list.pg_field
+#define tail_par                           cur_list.tail_field
+#define head_par                           cur_list.head_field
+#define mode_par                           cur_list.mode_field
+#define dirs_par                           cur_list.dirs_field
+#define space_factor_par                   cur_list.space_factor_field
+#define incompleat_noad_par                cur_list.incompleat_noad_field
+#define mode_line_par                      cur_list.ml_field
+#define aux_par                            cur_list.eTeX_aux_field
+#define delim_par                          aux_par
+
+#define par_shape_par_ptr                  equiv(par_shape_loc)
+#define inter_line_penalties_par_ptr       equiv(inter_line_penalties_loc)
+#define club_penalties_par_ptr             equiv(club_penalties_loc)
+#define widow_penalties_par_ptr            equiv(widow_penalties_loc)
+#define display_widow_penalties_par_ptr    equiv(display_widow_penalties_loc)
+
+#define page_width_par                     dimen_par(page_width_code)
+#define page_height_par                    dimen_par(page_height_code)
+#define h_offset_par                       dimen_par(h_offset_code)
+#define v_offset_par                       dimen_par(v_offset_code)
+#define page_left_offset_par               dimen_par(page_left_offset_code)
+#define page_top_offset_par                dimen_par(page_top_offset_code)
+#define page_right_offset_par              dimen_par(page_right_offset_code)
+#define page_bottom_offset_par             dimen_par(page_bottom_offset_code)
+#define px_dimen_par                       dimen_par(px_dimen_code)
+
+#define max_dead_cycles_par                int_par(max_dead_cycles_code)
+#define output_box_par                     int_par(output_box_code)
+#define holding_inserts_par                int_par(holding_inserts_code)
+#define output_routine_par                 equiv(output_routine_loc)
+#define floating_penalty_par               int_par(floating_penalty_code)
+
+#define mag_par                            int_par(mag_code)
+
+#define global_defs_par                    int_par(global_defs_code)
+#define cat_code_table_par                 int_par(cat_code_table_code)
+#define saving_vdiscards_par               int_par(saving_vdiscards_code)
+
+#define tracing_output_par                 int_par(tracing_output_code)
+#define tracing_stats_par                  int_par(tracing_stats_code)
+#define tracing_online_par                 int_par(tracing_online_code)
+#define tracing_paragraphs_par             int_par(tracing_paragraphs_code)
+#define tracing_nesting_par                int_par(tracing_nesting_code)
+#define tracing_lost_chars_par             int_par(tracing_lost_chars_code)
+#define tracing_scan_tokens_par            int_par(tracing_scan_tokens_code)
+#define tracing_ifs_par                    int_par(tracing_ifs_code)
+#define tracing_commands_par               int_par(tracing_commands_code)
+#define tracing_macros_par                 int_par(tracing_macros_code)
+#define tracing_assigns_par                int_par(tracing_assigns_code)
+#define tracing_fonts_par                  int_par(tracing_fonts_code)
+#define tracing_pages_par                  int_par(tracing_pages_code)
+#define tracing_restores_par               int_par(tracing_restores_code)
+#define tracing_groups_par                 int_par(tracing_groups_code)
+
+#define show_box_depth_par                 int_par(show_box_depth_code)
+#define show_box_breadth_par               int_par(show_box_breadth_code)
+
+#define pausing_par                        int_par(pausing_code)
+
+#define suppress_outer_error_par           int_par(suppress_outer_error_code)
+#define suppress_long_error_par            int_par(suppress_long_error_code)
+#define suppress_mathpar_error_par         int_par(suppress_mathpar_error_code)
+#define suppress_fontnotfound_error_par    int_par(suppress_fontnotfound_error_code)
+#define suppress_ifcsname_error_par        int_par(suppress_ifcsname_error_code)
+#define error_context_lines_par            int_par(error_context_lines_code)
+
+#define math_old_par                       mathoption_int_par(c_mathoption_old_code)
+#define math_no_italic_compensation_par    mathoption_int_par(c_mathoption_no_italic_compensation_code)
+#define math_no_char_italic_par            mathoption_int_par(c_mathoption_no_char_italic_code)
+#define math_use_old_fraction_scaling_par  mathoption_int_par(c_mathoption_use_old_fraction_scaling_code)
+#define math_umathcode_meaning_par         mathoption_int_par(c_mathoption_umathcode_meaning_code)
+
+#define time_par                           int_par(time_code)
+#define day_par                            int_par(day_code)
+#define month_par                          int_par(month_code)
+#define year_par                           int_par(year_code)
+
+#define output_mode_par                    int_par(output_mode_code)
+#define draft_mode_par                     int_par(draft_mode_code)
+#define synctex_par                        int_par(synctex_code)
+
+#define language_par                       int_par(language_code)
+#define uc_hyph_par                        int_par(uc_hyph_code)
+#define left_hyphen_min_par                int_par(left_hyphen_min_code)
+#define right_hyphen_min_par               int_par(right_hyphen_min_code)
+#define ex_hyphen_char_par                 int_par(ex_hyphen_char_code)
+#define hyphen_penalty_par                 int_par(hyphen_penalty_code)
+#define ex_hyphen_penalty_par              int_par(ex_hyphen_penalty_code)
+#define default_hyphen_char_par            int_par(default_hyphen_char_code)
+#define default_skew_char_par              int_par(default_skew_char_code)
+#define saving_hyph_codes_par              int_par(saving_hyph_codes_code)
+
+#define cur_lang_par                       int_par(cur_lang_code)
+#define cur_font_par                       equiv(cur_font_loc)
+
+/* */
 
 #define math_use_current_family_code 7
 
+/*
+    #define box(A) equiv(box_base+(A))
+    #define box(A) eqtb[box_base+(A)].hh.rh
+*/
+
+#define attribute(A) equiv(attribute_base+(A))
+#define box(A)       equiv(box_base+(A))
+#define count(A)     equiv(count_base+(A))
+#define dimen(A)     equiv(scaled_base+(A))
+#define mu_skip(A)   equiv(mu_skip_base+(A))
+#define skip(A)      equiv(skip_base+(A))
+#define toks(A)      equiv(toks_base+(A))
+
+#define get_tex_attribute_register(j) attribute(j)
+#define get_tex_box_register(j)       box(j)
+#define get_tex_count_register(j)     count(j)
+#define get_tex_dimen_register(j)     dimen(j)
+#define get_tex_mu_skip_register(j)   mu_skip(j)
+#define get_tex_skip_register(j)      skip(j)
+
+#define font_id_text(A) cs_text(font_id_base+(A))
+
+#define end_template_token  (cs_token_flag+frozen_end_template)
+#define end_write_token     (cs_token_flag+end_write)
+
 #endif
diff --git a/source/texk/web2c/luatexdir/tex/equivalents.w b/source/texk/web2c/luatexdir/tex/equivalents.w
index 62dd0736157bc7b23fcafcc4a9565d37267179e8..271fc67ffbd405820664563890f679f3800eadc9 100644
--- a/source/texk/web2c/luatexdir/tex/equivalents.w
+++ b/source/texk/web2c/luatexdir/tex/equivalents.w
@@ -37,8 +37,6 @@ static void diagnostic_trace(halfword p, const char *s)
 }
 
 @ @c
-#define par_shape_ptr equiv(par_shape_loc)
-
 void show_eqtb_meaning(halfword n);     /* forward */
 
 @ Now that we have studied the data structures for \TeX's semantic routines,
@@ -216,7 +214,7 @@ void new_save_level(group_code c)
     /* quit if |(cur_level+1)| is too big to be stored in |eqtb| */
     cur_boundary = save_ptr;
     cur_group = c;
-    if (int_par(tracing_groups_code) > 0)
+    if (tracing_groups_par > 0)
         group_trace(false);
     incr(cur_level);
     incr(save_ptr);
@@ -627,7 +625,7 @@ the call, since |eq_save| makes the necessary test.
 @c
 void eq_define(halfword p, quarterword t, halfword e)
 {
-    boolean trace = int_par(tracing_assigns_code) > 0;
+    boolean trace = tracing_assigns_par > 0;
     if ((eq_type(p) == t) && (equiv(p) == e)) {
         if (trace)
             diagnostic_trace(p, "reassigning");
@@ -654,7 +652,7 @@ void eq_define(halfword p, quarterword t, halfword e)
 @c
 void eq_word_define(halfword p, int w)
 {
-    boolean trace = int_par(tracing_assigns_code) > 0;
+    boolean trace = tracing_assigns_par > 0;
     if (eqtb[p].cint == w) {
         if (trace)
             diagnostic_trace(p, "reassigning");
@@ -680,7 +678,7 @@ to save old values, and the new value is associated with |level_one|.
 @c
 void geq_define(halfword p, quarterword t, halfword e)
 {                               /* global |eq_define| */
-    boolean trace = int_par(tracing_assigns_code) > 0;
+    boolean trace = tracing_assigns_par > 0;
     if (trace)
         diagnostic_trace(p, "globally changing");
     eq_destroy(eqtb[p]);
@@ -693,7 +691,7 @@ void geq_define(halfword p, quarterword t, halfword e)
 
 void geq_word_define(halfword p, int w)
 {                               /* global |eq_word_define| */
-    boolean trace = int_par(tracing_assigns_code) > 0;
+    boolean trace = tracing_assigns_par > 0;
     if (trace)
         diagnostic_trace(p, "globally changing");
     eqtb[p].cint = w;
@@ -727,11 +725,11 @@ void unsave(void)
     quarterword l = level_one;  /* saved level, if in fullword regions of |eqtb| */
     boolean a = false;          /* have we already processed an \.{\\aftergroup} ? */
     unsave_math_codes(cur_level);
-    unsave_cat_codes(int_par(cat_code_table_code), cur_level);
+    unsave_cat_codes(cat_code_table_par, cur_level);
     unsave_text_codes(cur_level);
     unsave_math_data(cur_level);
     if (cur_level > level_one) {
-        boolean trace = int_par(tracing_restores_code) > 0;
+        boolean trace = tracing_restores_par > 0;
         decr(cur_level);
         /* Clear off top level from |save_stack| */
         while (true) {
@@ -778,7 +776,7 @@ void unsave(void)
                 }
             }
         }
-        if (int_par(tracing_groups_code) > 0)
+        if (tracing_groups_par > 0)
             group_trace(true);
         if (grp_stack[in_open] == cur_boundary)
             group_warning();    /* groups possibly not properly nested with files */
@@ -804,13 +802,11 @@ int mag_set = 0; /* if nonzero, this magnification should be used henceforth */
 for magnification.
 
 @c
-#define mag int_par(mag_code)
-
 void prepare_mag(void)
 {
-    if ((mag_set > 0) && (mag != mag_set)) {
+    if ((mag_set > 0) && (mag_par != mag_set)) {
         print_err("Incompatible magnification (");
-        print_int(mag);
+        print_int(mag_par);
         tprint(");");
         tprint_nl(" the previous value will be retained");
         help2("I can handle only one magnification ratio per job. So I've",
@@ -818,19 +814,19 @@ void prepare_mag(void)
         int_error(mag_set);
         geq_word_define(int_base + mag_code, mag_set);  /* |mag:=mag_set| */
     }
-    if ((mag <= 0) || (mag > 32768)) {
+    if ((mag_par <= 0) || (mag_par > 32768)) {
         print_err("Illegal magnification has been changed to 1000");
         help1("The magnification ratio must be between 1 and 32768.");
-        int_error(mag);
+        int_error(mag_par);
         geq_word_define(int_base + mag_code, 1000);
     }
-    if ((mag_set == 0) && (mag != mag_set)) {
-        if (mag != 1000)
-            one_true_inch = xn_over_d(one_hundred_inch, 10, mag);
+    if ((mag_set == 0) && (mag_par != mag_set)) {
+        if (mag_par != 1000)
+            one_true_inch = xn_over_d(one_hundred_inch, 10, mag_par);
         else
             one_true_inch = one_inch;
     }
-    mag_set = mag;
+    mag_set = mag_par;
 }
 
 @ Let's pause a moment now and try to look at the Big Picture.
@@ -888,8 +884,6 @@ halfword cur_tok;               /* packed representative of |cur_cmd| and |cur_c
 @ Here is a procedure that displays the current command.
 
 @c
-#define mode cur_list.mode_field
-
 void show_cur_cmd_chr(void)
 {
     int n;                      /* level of \.{\\if...\\fi} nesting */
@@ -897,13 +891,13 @@ void show_cur_cmd_chr(void)
     halfword p;
     begin_diagnostic();
     tprint_nl("{");
-    if (mode != shown_mode) {
-        print_mode(mode);
+    if (mode_par != shown_mode) {
+        print_mode(mode_par);
         tprint(": ");
-        shown_mode = mode;
+        shown_mode = mode_par;
     }
     print_cmd_chr((quarterword) cur_cmd, cur_chr);
-    if (int_par(tracing_ifs_code) > 0) {
+    if (tracing_ifs_par > 0) {
         if (cur_cmd >= if_test_cmd) {
             if (cur_cmd <= fi_or_else_cmd) {
                 tprint(": ");
@@ -1013,7 +1007,7 @@ void show_eqtb(halfword n)
                 if (penalty(equiv(n)) > 1)
                     tprint_esc("ETC.");
             } else {
-                print_int(vinfo(par_shape_ptr + 1));
+                print_int(vinfo(par_shape_par_ptr + 1));
             }
         } else if (n < toks_base) {
             print_cmd_chr(assign_toks_cmd, n);
diff --git a/source/texk/web2c/luatexdir/tex/errors.w b/source/texk/web2c/luatexdir/tex/errors.w
index 29dea17d12c7bf010378cf19211510662029e0dd..4cad07c6f28f9efa7b8b6601e85ea5a901e7470a 100644
--- a/source/texk/web2c/luatexdir/tex/errors.w
+++ b/source/texk/web2c/luatexdir/tex/errors.w
@@ -25,9 +25,6 @@ luafflib.c
 @ @c
 #include "ptexlib.h"
 
-@ @c
-#define new_line_char int_par(new_line_char_code)
-
 @ When something anomalous is detected, \TeX\ typically does something like this:
 $$\vbox{\halign{#\hfil\cr
 |print_err("Something anomalous has been detected");|\cr
@@ -72,9 +69,9 @@ void set_last_error_context(void)
     int saved_new_line_char;
     int saved_new_string_line;
     selector = new_string;
-    saved_new_line_char = new_line_char;
+    saved_new_line_char = new_line_char_par;
     saved_new_string_line = new_string_line;
-    new_line_char = 10;
+    new_line_char_par = 10;
     new_string_line = 10;
     show_context();
     xfree(last_error_context);
@@ -82,7 +79,7 @@ void set_last_error_context(void)
     last_error_context = makecstring(str);
     flush_str(str);
     selector = sel;
-    new_line_char = saved_new_line_char;
+    new_line_char_par = saved_new_line_char;
     new_string_line = saved_new_string_line;
     return;
 }
@@ -634,10 +631,10 @@ void char_warning(internal_font_number f, int c)
 {
     int old_setting;            /* saved value of |tracing_online| */
     int k;                      /* index to current digit; we assume that $0\L n<16^{22}$ */
-    if (int_par(tracing_lost_chars_code) > 0) {
-        old_setting = int_par(tracing_online_code);
-        if (int_par(tracing_lost_chars_code) > 1)
-            int_par(tracing_online_code) = 1;
+    if (tracing_lost_chars_par > 0) {
+        old_setting = tracing_online_par;
+        if (tracing_lost_chars_par > 1)
+            tracing_online_par = 1;
         begin_diagnostic();
         tprint_nl("Missing character: There is no ");
         print(c);
@@ -659,7 +656,7 @@ void char_warning(internal_font_number f, int c)
         print_font_name(f);
         print_char('!');
         end_diagnostic(false);
-        int_par(tracing_online_code) = old_setting;
+        tracing_online_par = old_setting;
     }
 }
 
@@ -742,8 +739,8 @@ void normal_warning(const char *t, const char *p)
     int report_id ;
     if (strcmp(t,"lua") == 0) {
         int saved_new_line_char;
-        saved_new_line_char = new_line_char;
-        new_line_char = 10;
+        saved_new_line_char = new_line_char_par;
+        new_line_char_par = 10;
         report_id = callback_defined(show_lua_error_hook_callback);
         if (report_id == 0) {
             tprint(p);
@@ -753,7 +750,7 @@ void normal_warning(const char *t, const char *p)
             (void) run_callback(report_id, "->");
         }
         error();
-        new_line_char = saved_new_line_char;
+        new_line_char_par = saved_new_line_char;
     } else {
         report_id = callback_defined(show_warning_message_callback);
         if (report_id > 0) {
diff --git a/source/texk/web2c/luatexdir/tex/expand.w b/source/texk/web2c/luatexdir/tex/expand.w
index 46c8622b49149cf72d1cc2998168ee85b0dd6ce5..731345eb66e27d56028699f506c1b7ce3658eca1 100644
--- a/source/texk/web2c/luatexdir/tex/expand.w
+++ b/source/texk/web2c/luatexdir/tex/expand.w
@@ -80,7 +80,7 @@ void expand(void)
   RESWITCH:
     if (cur_cmd < call_cmd) {
         /* Expand a nonmacro */
-        if (int_par(tracing_commands_code) > 1)
+        if (tracing_commands_par > 1)
             show_cur_cmd_chr();
         switch (cur_cmd) {
         case top_bot_mark_cmd:
@@ -247,8 +247,8 @@ void expand(void)
                code, which is actually part of |expand|. It comes into play when
                \.{\\or}, \.{\\else}, or \.{\\fi} is scanned. */
 
-            if (int_par(tracing_ifs_code) > 0)
-                if (int_par(tracing_commands_code) <= 1)
+            if (tracing_ifs_par > 0)
+                if (tracing_commands_par <= 1)
                     show_cur_cmd_chr();
             if (cur_chr > if_limit) {
                 if (if_limit == if_code) {
@@ -554,7 +554,7 @@ void macro_call(void)
     warning_index = cur_cs;
     ref_count = cur_chr;
     r = token_link(ref_count);
-    if (int_par(tracing_macros_code) > 0) {
+    if (tracing_macros_par > 0) {
         /* Show the text of the macro being expanded */
         begin_diagnostic();
         print_ln();
@@ -686,7 +686,7 @@ void macro_call(void)
 
             if (cur_tok == par_token)
                 if (long_state != long_call_cmd)
-                    if (!int_par(suppress_long_error_code)) {
+                    if (!suppress_long_error_par) {
                         goto RUNAWAY;
                     }
             if (cur_tok < right_brace_limit) {
@@ -698,7 +698,7 @@ void macro_call(void)
                         get_token();
                         if (cur_tok == par_token) {
                             if (long_state != long_call_cmd) {
-                                if (!int_par(suppress_long_error_code)) {
+                                if (!suppress_long_error_par) {
                                     goto RUNAWAY;
 
                                 }
@@ -768,7 +768,7 @@ void macro_call(void)
                     pstack[n] = token_link(temp_token_head);
                 }
                 incr(n);
-                if (int_par(tracing_macros_code) > 0) {
+                if (tracing_macros_par > 0) {
                     begin_diagnostic();
                     print_nl(match_chr);
                     print_int(n);
diff --git a/source/texk/web2c/luatexdir/tex/extensions.w b/source/texk/web2c/luatexdir/tex/extensions.w
index f787e936092342ffbda45a663e1c9621f1adf127..feff6e382772e13136feee40d5e3206dda39524b 100644
--- a/source/texk/web2c/luatexdir/tex/extensions.w
+++ b/source/texk/web2c/luatexdir/tex/extensions.w
@@ -24,18 +24,10 @@
 #include "ptexlib.h"
 
 @ @c
-#define mode          cur_list.mode_field
-#define tail          cur_list.tail_field
-#define head          cur_list.head_field
-#define prev_graf     cur_list.pg_field
-#define dir_save      cur_list.dirs_field
-
-#define tracing_nesting int_par(tracing_nesting_code)
-#define tracing_online int_par(tracing_online_code)
-#define box(A) eqtb[box_base+(A)].hh.rh
-#define global_defs int_par(global_defs_code)
-#define cat_code_table int_par(cat_code_table_code)
-#define toks(A) equiv(toks_base+(A))
+#define mode     mode_par
+#define tail     tail_par
+#define head     head_par
+#define dir_save dirs_par
 
 @ The program above includes a bunch of ``hooks'' that allow further
 capabilities to be added without upsetting \TeX's basic structure.
@@ -477,8 +469,6 @@ above.) If it were not removed, and if there were numerous writes on a
 single page, the stack would overflow.
 
 @c
-#define end_write_token cs_token_flag+end_write
-
 void expand_macros_in_tokenlist(halfword p)
 {
     int old_mode;
@@ -741,7 +731,7 @@ void group_warning(void)
         /* Set variable |w| to indicate if this case should be reported */
         /* This code scans the input stack in order to determine the type of the
            current input file. */
-        if (tracing_nesting > 0) {
+        if (tracing_nesting_par > 0) {
             while ((input_stack[base_ptr].state_field == token_list) ||
                    (input_stack[base_ptr].index_field > i))
                 decr(base_ptr);
@@ -757,7 +747,7 @@ void group_warning(void)
         print_group(true);
         tprint(" of a different file");
         print_ln();
-        if (tracing_nesting > 1)
+        if (tracing_nesting_par > 1)
             show_context();
         if (history == spotless)
             history = warning_issued;
@@ -778,7 +768,7 @@ void if_warning(void)
     input_stack[base_ptr] = cur_input;  /* store current state */
     while (if_stack[i] == cond_ptr) {
         /* Set variable |w| to... */
-        if (tracing_nesting > 0) {
+        if (tracing_nesting_par > 0) {
             while ((input_stack[base_ptr].state_field == token_list) ||
                    (input_stack[base_ptr].index_field > i))
                 decr(base_ptr);
@@ -795,7 +785,7 @@ void if_warning(void)
         print_if_line(if_line);
         tprint(" of a different file");
         print_ln();
-        if (tracing_nesting > 1)
+        if (tracing_nesting_par > 1)
             show_context();
         if (history == spotless)
             history = warning_issued;
@@ -847,7 +837,7 @@ void file_warning(void)
     cur_if = c;
     if_line = i;                /* restore old values */
     print_ln();
-    if (tracing_nesting > 1)
+    if (tracing_nesting_par > 1)
         show_context();
     if (history == spotless)
         history = warning_issued;
@@ -862,9 +852,6 @@ internal stuff has to be accessed from C directly, where lots of the
 defines are not available.
 
 @c
-#define dimen(A) eqtb[scaled_base+(A)].hh.rh
-#define count(A) eqtb[count_base+(A)].hh.rh
-
 #define get_tex_dimen_register(j) dimen(j)
 #define get_tex_skip_register(j) skip(j)
 #define get_tex_mu_skip_register(j) mu_skip(j)
@@ -902,7 +889,7 @@ int get_tex_extension_toks_register(int i)
 int set_tex_dimen_register(int j, scaled v)
 {
     int a;                      /* return non-nil for error */
-    if (global_defs > 0)
+    if (global_defs_par > 0)
         a = 4;
     else
         a = 0;
@@ -913,7 +900,7 @@ int set_tex_dimen_register(int j, scaled v)
 int set_tex_skip_register(int j, halfword v)
 {
     int a;                      /* return non-nil for error */
-    if (global_defs > 0)
+    if (global_defs_par > 0)
         a = 4;
     else
         a = 0;
@@ -926,7 +913,7 @@ int set_tex_skip_register(int j, halfword v)
 int set_tex_mu_skip_register(int j, halfword v)
 {
     int a;                      /* return non-nil for error */
-    if (global_defs > 0)
+    if (global_defs_par > 0)
         a = 4;
     else
         a = 0;
@@ -939,7 +926,7 @@ int set_tex_mu_skip_register(int j, halfword v)
 int set_tex_count_register(int j, scaled v)
 {
     int a;                      /* return non-nil for error */
-    if (global_defs > 0)
+    if (global_defs_par > 0)
         a = 4;
     else
         a = 0;
@@ -950,7 +937,7 @@ int set_tex_count_register(int j, scaled v)
 int set_tex_box_register(int j, scaled v)
 {
     int a;                      /* return non-nil for error */
-    if (global_defs > 0)
+    if (global_defs_par > 0)
         a = 4;
     else
         a = 0;
@@ -961,7 +948,7 @@ int set_tex_box_register(int j, scaled v)
 int set_tex_attribute_register(int j, scaled v)
 {
     int a;                      /* return non-nil for error */
-    if (global_defs > 0)
+    if (global_defs_par > 0)
         a = 4;
     else
         a = 0;
@@ -988,7 +975,7 @@ int set_tex_toks_register(int j, lstring s)
     (void) str_toks(s);
     set_token_ref_count(ref, 0);
     set_token_link(ref, token_link(temp_token_head));
-    if (global_defs > 0)
+    if (global_defs_par > 0)
         a = 4;
     else
         a = 0;
@@ -1003,7 +990,7 @@ int scan_tex_toks_register(int j, int c, lstring s)
     (void) str_scan_toks(c,s);
     set_token_ref_count(ref, 0);
     set_token_link(ref, token_link(temp_token_head));
-    if (global_defs > 0)
+    if (global_defs_par > 0)
         a = 4;
     else
         a = 0;
diff --git a/source/texk/web2c/luatexdir/tex/inputstack.w b/source/texk/web2c/luatexdir/tex/inputstack.w
index be4cf9378e4a5f0018c27a1608b8698eafa09d65..68b22e1a334670fa6955b6126be5ea45c145063b 100644
--- a/source/texk/web2c/luatexdir/tex/inputstack.w
+++ b/source/texk/web2c/luatexdir/tex/inputstack.w
@@ -22,15 +22,11 @@
 #include "ptexlib.h"
 
 @ @c
-#define end_line_char int_par(end_line_char_code)
-#define error_context_lines int_par(error_context_lines_code)
-
 in_state_record *input_stack = NULL;
 int input_ptr = 0;              /* first unused location of |input_stack| */
 int max_in_stack = 0;           /* largest value of |input_ptr| when pushing */
 in_state_record cur_input;      /* the ``top'' input state */
 
-
 int in_open = 0;                /* the number of lines in the buffer, less one */
 int open_parens = 0;            /* the number of open text files */
 alpha_file *input_file = NULL;
@@ -39,7 +35,6 @@ int *line_stack = NULL;
 str_number *source_filename_stack = NULL;
 char **full_source_filename_stack = NULL;
 
-
 int scanner_status = 0;         /* can a subfile end now? */
 pointer warning_index = null;   /* identifier relevant to non-|normal| scanner status */
 pointer def_ref = null;         /* reference count of token list being defined */
@@ -235,7 +230,7 @@ void set_trick_count(void)
 
 #define PSEUDO_PRINT_THE_LINE()	do { \
     begin_pseudoprint(); \
-    if (buffer[ilimit]==end_line_char) \
+    if (buffer[ilimit]==end_line_char_par) \
         j=ilimit; \
     else \
         j=ilimit+1; /* determine the effective end of the line */ \
@@ -300,7 +295,7 @@ void show_context(void)
             if ((iname > 21) || (base_ptr == 0))
                 bottom_line = true;
         }
-        if ((base_ptr == input_ptr) || bottom_line || (nn < error_context_lines)) {
+        if ((base_ptr == input_ptr) || bottom_line || (nn < error_context_lines_par)) {
             /* Display the current context */
             if ((base_ptr == input_ptr) || (istate != token_list) || (token_type != backed_up) || (iloc != null)) {
                 /* we omit backed-up token lists that have already been read */
@@ -381,10 +376,10 @@ void show_context(void)
                     tprint("...");
                 incr(nn);
             }
-        } else if (nn == error_context_lines) {
+        } else if (nn == error_context_lines_par) {
             tprint_nl("...");
             incr(nn);
-            /* omitted if |error_context_lines<0| */
+            /* omitted if |error_context_lines_par<0| */
         }
         if (bottom_line)
             break;
@@ -435,7 +430,7 @@ void begin_token_list(halfword p, quarterword t)
             param_start = param_ptr;
         } else {
             iloc = token_link(p);
-            if (int_par(tracing_macros_code) > 1) {
+            if (tracing_macros_par > 1) {
                 begin_diagnostic();
                 tprint_nl("");
                 if (t == mark_text)
@@ -726,7 +721,7 @@ void pseudo_from_string(void)
     halfword p;    /* for list construction */
     s = make_string();
     /* Convert string |s| into a new pseudo file */
-    p = string_to_pseudo(s, int_par(new_line_char_code));
+    p = string_to_pseudo(s, new_line_char_par);
     vlink(p) = pseudo_files;
     pseudo_files = p;
     flush_str(s);
@@ -735,7 +730,7 @@ void pseudo_from_string(void)
     line = 0;
     ilimit = istart;
     iloc = ilimit + 1; /* force line read */
-    if (int_par(tracing_scan_tokens_code) > 0) {
+    if (tracing_scan_tokens_par > 0) {
         if (term_offset > max_print_line - 3)
             print_ln();
         else if ((term_offset > 0) || (file_offset > 0))
diff --git a/source/texk/web2c/luatexdir/tex/linebreak.w b/source/texk/web2c/luatexdir/tex/linebreak.w
index 6e74e0b27becf2aa33e959126e5b1c8b12ec7eb9..fb67eb2fcece6d47857202e0c386618deccd7ef2 100644
--- a/source/texk/web2c/luatexdir/tex/linebreak.w
+++ b/source/texk/web2c/luatexdir/tex/linebreak.w
@@ -146,7 +146,7 @@ void line_break(boolean d, int line_break_context)
                 succumb();
             }
         } else {
-            if (int_par(tracing_paragraphs_code) > 0) {
+            if (tracing_paragraphs_par > 0) {
                 begin_diagnostic();
                 print_int(line);
                 end_diagnostic(true);
@@ -160,31 +160,31 @@ void line_break(boolean d, int line_break_context)
             confusion("weird par dir"); /* assert(0); */ /* |paragraph_dir = 0|; */
         }
         ext_do_line_break(paragraph_dir,
-                          int_par(pretolerance_code),
-                          int_par(tracing_paragraphs_code),
-                          int_par(tolerance_code),
-                          dimen_par(emergency_stretch_code),
-                          int_par(looseness_code),
-                          int_par(adjust_spacing_code),
-                          equiv(par_shape_loc),
-                          int_par(adj_demerits_code),
-                          int_par(protrude_chars_code),
-                          int_par(line_penalty_code),
-                          int_par(last_line_fit_code),
-                          int_par(double_hyphen_demerits_code),
-                          int_par(final_hyphen_demerits_code),
-                          dimen_par(hang_indent_code),
-                          dimen_par(hsize_code),
-                          int_par(hang_after_code),
-                          glue_par(left_skip_code),
-                          glue_par(right_skip_code),
-                          equiv(inter_line_penalties_loc),
-                          int_par(inter_line_penalty_code),
-                          int_par(club_penalty_code),
-                          equiv(club_penalties_loc),
-                          (d ? equiv(display_widow_penalties_loc) : equiv(widow_penalties_loc)),
-                          (d ? int_par(display_widow_penalty_code) : int_par(widow_penalty_code)),
-                          int_par(broken_penalty_code),
+                          pretolerance_par,
+                          tracing_paragraphs_par,
+                          tolerance_par,
+                          emergency_stretch_par,
+                          looseness_par,
+                          adjust_spacing_par,
+                          par_shape_par_ptr,
+                          adj_demerits_par,
+                          protrude_chars_par,
+                          line_penalty_par,
+                          last_line_fit_par,
+                          double_hyphen_demerits_par,
+                          final_hyphen_demerits_par,
+                          hang_indent_par,
+                          hsize_par,
+                          hang_after_par,
+                          left_skip_par,
+                          right_skip_par,
+                          inter_line_penalties_par_ptr,
+                          inter_line_penalty_par,
+                          club_penalty_par,
+                          club_penalties_par_ptr,
+                          (d ? display_widow_penalties_par_ptr : widow_penalties_par_ptr),
+                          (d ? display_widow_penalty_code : widow_penalty_code),
+                          broken_penalty_par,
                           final_par_glue);
     }
     lua_node_filter(post_linebreak_filter_callback,
@@ -898,7 +898,7 @@ static void compute_break_width(int break_type, int line_break_dir, int adjust_s
         switch (type(s)) {
             case math_node:
                 /* begin mathskip code */
-                if (glue_is_zero(math_skip)) {
+                if (glue_is_zero(math_skip_par)) {
                     break_width[1] -= surround(s);
                     break;
                 } else {
@@ -1630,14 +1630,15 @@ void ext_do_line_break(int paragraph_dir,
             second_width = hsize;
             second_indent = 0;
         } else {
+            halfword used_hang_indent = swap_hang_indent(hang_indent);
             /*  Set line length parameters in preparation for hanging indentation */
             /* We compute the values of |easy_line| and the other local variables relating
                to line length when the |line_break| procedure is initializing itself. */
             last_special_line = abs(hang_after);
             if (hang_after < 0) {
-                first_width = hsize - abs(hang_indent);
-                if (hang_indent >= 0)
-                    first_indent = hang_indent;
+                first_width = hsize - abs(used_hang_indent);
+                if (used_hang_indent >= 0)
+                    first_indent = used_hang_indent;
                 else
                     first_indent = 0;
                 second_width = hsize;
@@ -1645,19 +1646,18 @@ void ext_do_line_break(int paragraph_dir,
             } else {
                 first_width = hsize;
                 first_indent = 0;
-                second_width = hsize - abs(hang_indent);
-                if (hang_indent >= 0)
-                    second_indent = hang_indent;
+                second_width = hsize - abs(used_hang_indent);
+                if (used_hang_indent >= 0)
+                    second_indent = used_hang_indent;
                 else
                     second_indent = 0;
             }
         }
     } else {
         last_special_line = vinfo(par_shape_ptr + 1) - 1;
-        second_indent =
-            varmem[(par_shape_ptr + 2 * (last_special_line + 1))].cint;
-        second_width =
-            varmem[(par_shape_ptr + 2 * (last_special_line + 1) + 1)].cint;
+        second_indent = varmem[(par_shape_ptr + 2 * (last_special_line + 1))].cint;
+        second_width = varmem[(par_shape_ptr + 2 * (last_special_line + 1) + 1)].cint;
+        second_indent = swap_parshape_indent(second_indent,second_width);
     }
     if (looseness == 0)
         easy_line = last_special_line;
@@ -1840,7 +1840,7 @@ void ext_do_line_break(int paragraph_dir,
                 case math_node:
                     auto_breaking = (subtype(cur_p) == after);
                     /* begin mathskip code */
-                    if (glue_is_zero(math_skip)) {
+                    if (glue_is_zero(math_skip_par)) {
                         kern_break();
                         break;
                     } else {
@@ -2132,7 +2132,7 @@ void ext_do_line_break(int paragraph_dir,
                         protrude_chars,
                         par_shape_ptr,
                         adjust_spacing,
-                        inter_line_penalties_ptr,
+                        inter_line_penalties_par_ptr,
                         inter_line_penalty,
                         club_penalty,
                         club_penalties_ptr,
diff --git a/source/texk/web2c/luatexdir/tex/mainbody.h b/source/texk/web2c/luatexdir/tex/mainbody.h
index fdef20ab882fc237526c3bc777b1875c3ed3516a..158893631d74d7b5159132d9a572d844e2f58916 100644
--- a/source/texk/web2c/luatexdir/tex/mainbody.h
+++ b/source/texk/web2c/luatexdir/tex/mainbody.h
@@ -214,8 +214,7 @@ is conditionally compiled in the C code.
 @^system dependencies@>
 */
 
-
-#  define fix_date_and_time() dateandtime(int_par(time_code),int_par(day_code),int_par(month_code),int_par(year_code))
+#  define fix_date_and_time() dateandtime(time_par,day_par,month_par,year_par)
 
 extern int get_luatexversion(void);
 extern str_number get_luatexrevision(void);
diff --git a/source/texk/web2c/luatexdir/tex/mainbody.w b/source/texk/web2c/luatexdir/tex/mainbody.w
index ad0bb783a1f0e5a2c501246cb69c42be6602a460..0fb8bc4b4847f33b704004bf0624aa7443f43c55 100644
--- a/source/texk/web2c/luatexdir/tex/mainbody.w
+++ b/source/texk/web2c/luatexdir/tex/mainbody.w
@@ -432,9 +432,9 @@ void main_body(void)
             incr(iloc);
     }
     if (output_mode_option != 0)
-        int_par(output_mode_code) = output_mode_value;
+        output_mode_par = output_mode_value;
     if (draft_mode_option != 0) {
-        int_par(draft_mode_code) = draft_mode_value;
+        draft_mode_par = draft_mode_value;
     }
     /* can this be moved? */
     pdf_init_map_file((char *) pdftex_map);
@@ -442,15 +442,14 @@ void main_body(void)
     if (end_line_char_inactive)
         decr(ilimit);
     else
-        buffer[ilimit] = (packed_ASCII_code) int_par(end_line_char_code);
+        buffer[ilimit] = (packed_ASCII_code) end_line_char_par;
     fix_date_and_time();
     random_seed = (microseconds * 1000) + (epochseconds % 1000000);
     init_randoms(random_seed);
     initialize_math();
     fixup_selector(log_opened_global);
     check_texconfig_init();
-    if ((iloc < ilimit) && (get_cat_code(int_par(cat_code_table_code),
-                                         buffer[iloc]) != escape_cmd))
+    if ((iloc < ilimit) && (get_cat_code(cat_code_table_code, buffer[iloc]) != escape_cmd))
         start_input();          /* \.{\\input} assumed */
     /* DIR: Initialize |text_dir_ptr| */
     text_dir_ptr = new_dir(0);
@@ -487,7 +486,7 @@ void close_files_and_terminate(void)
     int callback_id;
     callback_id = callback_defined(stop_run_callback);
     finalize_write_files();
-    if (int_par(tracing_stats_code) > 0) {
+    if (tracing_stats_par > 0) {
         if (callback_id == 0) {
             /* Output statistics about this job */
             /* The present section goes directly to the log file instead of using
diff --git a/source/texk/web2c/luatexdir/tex/maincontrol.h b/source/texk/web2c/luatexdir/tex/maincontrol.h
index c42dcc93aa4dd00301553ca1aa843f180fa89406..13e3c6ff3b0e39e58f52ce150839bbfcfc26038e 100644
--- a/source/texk/web2c/luatexdir/tex/maincontrol.h
+++ b/source/texk/web2c/luatexdir/tex/maincontrol.h
@@ -71,9 +71,9 @@ since the following routines test for the \.{\\global} prefix as follows.
 
 #  define define_cat_code(A,B) do {			\
      if (is_global(a))					\
-       set_cat_code(int_par(cat_code_table_code),(A),(B),level_one);	\
+       set_cat_code(cat_code_table_par,(A),(B),level_one);	\
      else						\
-       set_cat_code(int_par(cat_code_table_code),(A),(B),cur_level);	\
+       set_cat_code(cat_code_table_par,(A),(B),cur_level);	\
    } while (0)
 
 #  define define_fam_fnt(A,B,C) do {		\
@@ -174,6 +174,17 @@ extern void fixup_directions(void);
     tprint(" entered on line "); print_int((A));	\
   }
 
+/*
+    extern halfword swap_hang_indent(halfword indentation, halfword shape_mode);
+    extern halfword swap_parshape_indent(halfword indentation, halfword width, halfword shape_mode);
+*/
+
+#define swap_hang_indent(indentation) \
+    ( ((shape_mode_par == 1 || shape_mode_par == 3 || shape_mode_par == -1 || shape_mode_par == -3)) ? negate(indentation) : indentation )
+
+#define swap_parshape_indent(indentation,width) \
+    ( ((shape_mode_par == 2 || shape_mode_par == 3 || shape_mode_par == -2 || shape_mode_par == -3)) ? (hsize_par - width - indentation) : indentation )
+
 extern void get_r_token(void);
 extern void assign_internal_value(int a, halfword p, int cur_val);
 extern void do_register_command(int a);
diff --git a/source/texk/web2c/luatexdir/tex/maincontrol.w b/source/texk/web2c/luatexdir/tex/maincontrol.w
index 964e0419965151c5b101a654670016571579fe97..cbfd333bbb750661fa1d27e422bf3ac0f5001730 100644
--- a/source/texk/web2c/luatexdir/tex/maincontrol.w
+++ b/source/texk/web2c/luatexdir/tex/maincontrol.w
@@ -22,70 +22,11 @@
 #include "ptexlib.h"
 #include "lua/luatex-api.h"
 
-/* these will move to equivalents.h */
-
 @ @c
-#define lp_code_base 2
-#define rp_code_base 3
-#define ef_code_base 4
-#define tag_code 5
-#define no_lig_code 6
-#define gp_code_base 7
-
-#define prev_depth cur_list.prev_depth_field
-#define space_factor cur_list.space_factor_field
-#define par_shape_ptr  equiv(par_shape_loc)
-
-#define cur_lang int_par(cur_lang_code)
-#define global_defs int_par(global_defs_code)
-#define output_box int_par(output_box_code)
-#define end_line_char int_par(end_line_char_code)
-#define new_line_char int_par(new_line_char_code)
-#define tracing_online int_par(tracing_online_code)
-#define no_local_whatsits int_par(no_local_whatsits_code)
-#define no_local_dirs int_par(no_local_dirs_code)
-#define err_help equiv(err_help_loc)
-#define every_par equiv(every_par_loc)
-
-#define page_left_offset dimen_par(page_left_offset_code)
-#define page_top_offset dimen_par(page_top_offset_code)
-#define page_right_offset dimen_par(page_right_offset_code)
-#define page_bottom_offset dimen_par(page_bottom_offset_code)
-#define px_dimen dimen_par(px_dimen_code)
-
-#define math_eqno_gap_step int_par(math_eqno_gap_step_code)
-
-#define escape_char int_par(escape_char_code)
-#define max_dead_cycles int_par(max_dead_cycles_code)
-#define tolerance int_par(tolerance_code)
-#define mag int_par(mag_code)
-#define cat_code_table int_par(cat_code_table_code)
-
-#define par_indent dimen_par(par_indent_code)
-#define looseness int_par(looseness_code)
-#define space_skip glue_par(space_skip_code)
-#define xspace_skip glue_par(xspace_skip_code)
-#define math_skip glue_par(math_skip_code)
-#define every_vbox equiv(every_vbox_loc)
-
-#define split_top_skip glue_par(split_top_skip_code)
-#define split_max_depth dimen_par(split_max_depth_code)
-
-#define hang_indent dimen_par(hang_indent_code)
-#define hang_after int_par(hang_after_code)
-#define inter_line_penalties_ptr equiv(inter_line_penalties_loc)
-
-#define box(A) eqtb[box_base+(A)].hh.rh
-#define cur_font equiv(cur_font_loc)
-#define hsize dimen_par(hsize_code)
-#define ex_hyphen_char int_par(ex_hyphen_char_code)
-#define floating_penalty int_par(floating_penalty_code)
-
-#define mode          cur_list.mode_field
-#define tail          cur_list.tail_field
-#define head          cur_list.head_field
-#define prev_graf     cur_list.pg_field
-#define dir_save      cur_list.dirs_field
+#define mode     mode_par
+#define tail     tail_par
+#define head     head_par
+#define dir_save dirs_par
 
 @ We come now to the |main_control| routine, which contains the master
 switch that causes all the various pieces of \TeX\ to do their things,
@@ -138,14 +79,14 @@ void adjust_space_factor(void)
 {
     halfword s = get_sf_code(cur_chr);
     if (s == 1000) {
-        space_factor = 1000;
+        space_factor_par = 1000;
     } else if (s < 1000) {
         if (s > 0)
-            space_factor = s;
-    } else if (space_factor < 1000) {
-        space_factor = 1000;
+            space_factor_par = s;
+    } else if (space_factor_par < 1000) {
+        space_factor_par = 1000;
     } else {
-        space_factor = s;
+        space_factor_par = s;
     }
 }
 
@@ -177,12 +118,12 @@ static void run_char_num (void) {
     scan_char_num();
     cur_chr = cur_val;
     adjust_space_factor();
-    tail_append(new_char(cur_font, cur_chr));
+    tail_append(new_char(cur_font_par, cur_chr));
 }
 
 static void run_char (void) {
     adjust_space_factor();
-    tail_append(new_char(cur_font, cur_chr));
+    tail_append(new_char(cur_font_par, cur_chr));
 }
 
 @
@@ -199,23 +140,23 @@ is zero or~not.
 @c
 static void run_app_space (void) {
     halfword p; /* was a global temp_ptr */
-    int method = int_par(disable_space_code) ;
+    int method = disable_space_par ;
     if (method == 1) {
         /* don't inject anything, not even zero skip */
     } else if (method == 2) {
         p = new_glue(zero_glue);
         couple_nodes(tail,p);
         tail = p;
-    } else if ((abs(mode) + cur_cmd == hmode + spacer_cmd) && (!(space_factor == 1000))) {
+    } else if ((abs(mode) + cur_cmd == hmode + spacer_cmd) && (!(space_factor_par == 1000))) {
         app_space();
     } else {
         /* Append a normal inter-word space to the current list */
-        if (glue_is_zero(space_skip)) {
+        if (glue_is_zero(space_skip_par)) {
             /* Find the glue specification for text spaces in the current font */
             p = new_glue(zero_glue);
-            width(p) = space(cur_font);
-            stretch(p) = space_stretch(cur_font);
-            shrink(p) = space_shrink(cur_font);
+            width(p) = space(cur_font_par);
+            stretch(p) = space_stretch(cur_font_par);
+            shrink(p) = space_shrink(cur_font_par);
 
         } else {
             p = new_param_glue(space_skip_code);
@@ -349,9 +290,9 @@ mode, by setting |prev_depth:=ignore_depth|.
 static void run_rule (void) {
     tail_append(scan_rule_spec());
     if (abs(mode) == vmode)
-        prev_depth = ignore_depth;
+        prev_depth_par = ignore_depth;
     else if (abs(mode) == hmode)
-        space_factor = 1000;
+        space_factor_par = 1000;
 }
 
 @
@@ -565,9 +506,9 @@ static void run_vcenter (void) {
     normal_paragraph();
     push_nest();
     mode = -vmode;
-    prev_depth = ignore_depth;
-    if (every_vbox != null)
-        begin_token_list(every_vbox, every_vbox_text);
+    prev_depth_par = ignore_depth;
+    if (every_vbox_par != null)
+        begin_token_list(every_vbox_par, every_vbox_text);
 }
 
 @ @c
@@ -627,12 +568,12 @@ static void run_normal (void) {
                 help1("All \\catcode table ids must be between 0 and 0x7FFF");
                 error();
             } else {
-                if (cur_val == cat_code_table) {
+                if (cur_val == cat_code_table_par) {
                     print_err("Invalid \\catcode table");
                     help1("You cannot overwrite the current \\catcode table");
                     error();
                 } else {
-                    copy_cat_codes(cat_code_table, cur_val);
+                    copy_cat_codes(cat_code_table_par, cur_val);
                 }
             }
             break;
@@ -643,7 +584,7 @@ static void run_normal (void) {
                 help1("All \\catcode table ids must be between 0 and 0x7FFF");
                 error();
             } else {
-                if (cur_val == cat_code_table) {
+                if (cur_val == cat_code_table_par) {
                     print_err("Invalid \\catcode table");
                     help1("You cannot overwrite the current \\catcode table");
                     error();
@@ -963,7 +904,7 @@ void main_control(void)
             check_interrupt();
             continue;
         }
-        if (int_par(tracing_commands_code) > 0)
+        if (tracing_commands_par > 0)
             show_cur_cmd_chr();
 
         (jump_table[(abs(mode) + cur_cmd)])(); /* run the command */
@@ -979,24 +920,24 @@ void main_control(void)
 void app_space(void)
 {                               /* handle spaces when |space_factor<>1000| */
     halfword q;                 /* glue node */
-    if ((space_factor >= 2000) && (! glue_is_zero(xspace_skip))) {
+    if ((space_factor_par >= 2000) && (! glue_is_zero(xspace_skip_par))) {
         q = new_param_glue(xspace_skip_code);
         /* so from now we have a subtype with spaces: */
         subtype(q) = xspace_skip_code + 1;
     } else {
-        if (!glue_is_zero(space_skip)) {
-            q = new_glue(space_skip);
+        if (!glue_is_zero(space_skip_par)) {
+            q = new_glue(space_skip_par);
         } else {
             q = new_glue(zero_glue);
-            width(q) = space(cur_font);
-            stretch(q) = space_stretch(cur_font);
-            shrink(q) = space_shrink(cur_font);
+            width(q) = space(cur_font_par);
+            stretch(q) = space_stretch(cur_font_par);
+            shrink(q) = space_shrink(cur_font_par);
         }
         /* Modify the glue specification in |q| according to the space factor */
-        if (space_factor >= 2000)
-            width(q) = width(q) + extra_space(cur_font);
-        stretch(q) = xn_over_d(stretch(q), space_factor, 1000);
-        shrink(q) = xn_over_d(shrink(q), 1000, space_factor);
+        if (space_factor_par >= 2000)
+            width(q) = width(q) + extra_space(cur_font_par);
+        stretch(q) = xn_over_d(stretch(q), space_factor_par, 1000);
+        shrink(q) = xn_over_d(shrink(q), 1000, space_factor_par);
 
         /* so from now we have a subtype with spaces: */
         subtype(q) = space_skip_code + 1;
@@ -1021,7 +962,7 @@ void insert_dollar_sign(void)
 @c
 void insert_dollar_sign_par_end(void)
 {
-    if (!int_par(suppress_mathpar_error_code)) {
+    if (!suppress_mathpar_error_par) {
         insert_dollar_sign() ;
     }
 }
@@ -1092,7 +1033,7 @@ boolean its_all_over(void)
         }
         back_input();           /* we will try to end again after ejecting residual material */
         tail_append(new_null_box());
-        width(tail) = hsize;
+        width(tail) = hsize_par;
         tail_append(new_glue(fill_glue));
         tail_append(new_penalty(-010000000000));
         normal_page_filter(end);
@@ -1263,9 +1204,9 @@ void handle_right_brace(void)
             break;
         case insert_group:
             end_graf(insert_group);
-            q = new_glue(split_top_skip);
-            d = split_max_depth;
-            f = floating_penalty;
+            q = new_glue(split_top_skip_par);
+            d = split_max_depth_par;
+            f = floating_penalty_par;
             unsave();
             save_ptr--;
             /* now |saved_value(0)| is the insertion number, or the |vadjust| subtype */
@@ -1366,16 +1307,18 @@ default values after every paragraph and when internal vertical mode is entered.
 @c
 void normal_paragraph(void)
 {
-    if (looseness != 0)
+    if (looseness_par != 0)
         eq_word_define(int_base + looseness_code, 0);
-    if (hang_indent != 0)
+    if (hang_indent_par != 0)
         eq_word_define(dimen_base + hang_indent_code, 0);
-    if (hang_after != 1)
+    if (hang_after_par != 1)
         eq_word_define(int_base + hang_after_code, 1);
-    if (par_shape_ptr != null)
+    if (par_shape_par_ptr != null)
         eq_define(par_shape_loc, shape_ref_cmd, null);
-    if (inter_line_penalties_ptr != null)
+    if (inter_line_penalties_par_ptr != null)
         eq_define(inter_line_penalties_loc, shape_ref_cmd, null);
+    if (shape_mode_par > 0)
+        eq_word_define(dimen_base + shape_mode_code, 0);
 }
 
 @ The global variable |cur_box| will point to a newly-made box. If the box
@@ -1419,7 +1362,7 @@ void box_end(int box_context)
                 }
             } else {
                 if (abs(mode) == hmode)
-                    space_factor = 1000;
+                    space_factor_par = 1000;
                 else
                     cur_box = new_sub_box(cur_box);
                 couple_nodes(tail, cur_box);
@@ -1489,19 +1432,19 @@ void new_graf(boolean indented)
 {
     halfword p, q, dir_graf_tmp;
     halfword dir_rover;
-    prev_graf = 0;
+    prev_graf_par = 0;
     if ((mode == vmode) || (head != tail)) {
         tail_append(new_param_glue(par_skip_code));
     }
     push_nest();
     mode = hmode;
-    space_factor = 1000;
+    space_factor_par = 1000;
     /* LOCAL: Add local paragraph node */
     tail_append(make_local_par_node(new_graf_par_code));
     if (indented) {
         p = new_null_box();
-        box_dir(p) = par_direction;
-        width(p) = par_indent;
+        box_dir(p) = par_direction_par;
+        width(p) = par_indent_par;
         subtype(p) = indent_list;
         q = tail;
         tail_append(p);
@@ -1510,7 +1453,7 @@ void new_graf(boolean indented)
     }
     dir_rover = text_dir_ptr;
     while (dir_rover != null) {
-        if ((vlink(dir_rover) != null) || (dir_dir(dir_rover) != par_direction)) {
+        if ((vlink(dir_rover) != null) || (dir_dir(dir_rover) != par_direction_par)) {
             dir_graf_tmp = new_dir(dir_dir(dir_rover));
             try_couple_nodes(dir_graf_tmp,vlink(q));
             couple_nodes(q,dir_graf_tmp);
@@ -1521,8 +1464,8 @@ void new_graf(boolean indented)
     while (vlink(q) != null)
         q = vlink(q);
     tail = q;
-    if (every_par != null)
-        begin_token_list(every_par, every_par_text);
+    if (every_par_par != null)
+        begin_token_list(every_par_par, every_par_text);
     if (nest_ptr == 1) {
         checked_page_filter(new_graf);
         build_page();           /* put |par_skip| glue on current page */
@@ -1535,9 +1478,9 @@ void indent_in_hmode(void)
     halfword p;
     if (cur_chr > 0) {          /* \.{\\indent} */
         p = new_null_box();
-        width(p) = par_indent;
+        width(p) = par_indent_par;
         if (abs(mode) == hmode)
-            space_factor = 1000;
+            space_factor_par = 1000;
         else
             p = new_sub_box(p);
         tail_append(p);
@@ -1594,9 +1537,9 @@ void begin_insert_or_adjust(void)
 {
     if (cur_cmd != vadjust_cmd) {
         scan_register_num();
-        if (cur_val == output_box) {
+        if (cur_val == output_box_par) {
             print_err("You can't \\insert");
-            print_int(output_box);
+            print_int(output_box_par);
             help1("I'm changing to \\insert0; box \\outputbox is special.");
             error();
             cur_val = 0;
@@ -1613,7 +1556,7 @@ void begin_insert_or_adjust(void)
     normal_paragraph();
     push_nest();
     mode = -vmode;
-    prev_depth = ignore_depth;
+    prev_depth_par = ignore_depth;
 }
 
 @ I (TH)'ve renamed the |make_mark| procedure to this, because if the
@@ -1798,7 +1741,7 @@ void append_local_box(int kind)
     scan_left_brace();
     push_nest();
     mode = -hmode;
-    space_factor = 1000;
+    space_factor_par = 1000;
 }
 
 @ Discretionary nodes are easy in the common case `\.{\\-}', but in the
@@ -1815,19 +1758,19 @@ void append_discretionary(void)
     subtype(tail) = (quarterword) cur_chr;
     if (cur_chr == explicit_disc) {
         /* \- */
-        c = get_pre_hyphen_char(cur_lang);
+        c = get_pre_hyphen_char(cur_lang_par);
         if (c != 0) {
             vlink(pre_break(tail)) = new_char(equiv(cur_font_loc), c);
             alink(vlink(pre_break(tail))) = pre_break(tail);
             tlink(pre_break(tail)) = vlink(pre_break(tail));
         }
-        c = get_post_hyphen_char(cur_lang);
+        c = get_post_hyphen_char(cur_lang_par);
         if (c != 0) {
             vlink(post_break(tail)) = new_char(equiv(cur_font_loc), c);
             alink(vlink(post_break(tail))) = post_break(tail);
             tlink(post_break(tail)) = vlink(post_break(tail));
         }
-        disc_penalty(tail) = int_par(ex_hyphen_penalty_code);
+        disc_penalty(tail) = ex_hyphen_penalty_par;
     } else {
         /* \discretionary */
         if (scan_keyword("penalty")) {
@@ -1840,8 +1783,8 @@ void append_discretionary(void)
         scan_left_brace();
         push_nest();
         mode = -hmode;
-        space_factor = 1000;
-        /* already preset: disc_penalty(tail) = int_par(hyphen_penalty_code); */
+        space_factor_par = 1000;
+        /* already preset: disc_penalty(tail) = hyphen_penalty_par; */
     }
 }
 
@@ -1869,7 +1812,7 @@ void build_local_box(void)
         /* LOCAL: Add local paragraph node */
         tail_append(make_local_par_node(local_box_par_code));
     }
-    eq_word_define(int_base + no_local_whatsits_code, no_local_whatsits + 1);
+    eq_word_define(int_base + no_local_whatsits_code, no_local_whatsits_par + 1);
 }
 
 @ The three discretionary lists are constructed somewhat as if they were
@@ -1952,7 +1895,7 @@ void build_discretionary(void)
     scan_left_brace();
     push_nest();
     mode = -hmode;
-    space_factor = 1000;
+    space_factor_par = 1000;
 }
 
 @ The positioning of accents is straightforward but tedious. Given an accent
@@ -2021,7 +1964,7 @@ void make_accent(void)
         }
         couple_nodes(tail, p);
         tail = p;
-        space_factor = 1000;
+        space_factor_par = 1000;
     }
 }
 
@@ -2175,6 +2118,25 @@ following program is careful to check each case properly.
 } while (0)
 
 @ @c
+/*
+halfword swap_hang_indent(halfword indentation, halfword shape_mode) {
+    if (shape_mode == 1 || shape_mode == 3 || shape_mode == -1 || shape_mode == -3) {
+        return negate(indentation);
+    } else {
+        return indentation;
+    }
+}
+
+halfword swap_parshape_indent(halfword indentation, halfword width, halfword shape_mode) {
+    if (shape_mode == 2 || shape_mode == 3 || shape_mode == -2 || shape_mode == -3) {
+        return hsize_par - width - indentation;
+    } else {
+        return indentation;
+    }
+}
+
+*/
+
 void prefixed_command(void)
 {
     int a;                      /* accumulated prefix codes so far */
@@ -2182,7 +2144,7 @@ void prefixed_command(void)
     halfword j;                 /* index into a \.{\\parshape} specification */
     halfword p, q;              /* for temporary short-term use */
     int n;                      /* ditto */
-    boolean e;                  /* should a definition be expanded? or was \.{\\let} not done? */
+    boolean e, check_glue;      /* should a definition be expanded? or was \.{\\let} not done? */
     mathcodeval mval;           /* for handling of \.{\\mathchardef}s */
     a = 0;
     while (cur_cmd == prefix_cmd) {
@@ -2204,7 +2166,7 @@ void prefixed_command(void)
             back_error();
             return;
         }
-        if (int_par(tracing_commands_code) > 2)
+        if (tracing_commands_par > 2)
             show_cur_cmd_chr();
     }
     /* Discard the prefixes \.{\\long} and \.{\\outer} if they are irrelevant */
@@ -2222,8 +2184,8 @@ void prefixed_command(void)
         error();
     }
     /* Adjust for the setting of \.{\\globaldefs} */
-    if (global_defs != 0) {
-        if (global_defs < 0) {
+    if (global_defs_par != 0) {
+        if (global_defs_par < 0) {
             if (is_global(a))
                 a = a - 4;
         } else {
@@ -2242,7 +2204,7 @@ void prefixed_command(void)
                |cur_chr| is odd if the definition is supposed to be global, and
                |cur_chr>=2| if the definition is supposed to be expanded. */
 
-            if (odd(cur_chr) && !is_global(a) && (global_defs >= 0))
+            if (odd(cur_chr) && !is_global(a) && (global_defs_par >= 0))
                 a = a + 4;
             e = (cur_chr >= 2);
             get_r_token();
@@ -2323,7 +2285,7 @@ void prefixed_command(void)
                 break;
             case math_char_def_code:
                 mval = scan_mathchar(tex_mathcode);
-                if (mathoption_int_par(c_mathoption_umathcode_meaning_code) == 1) {
+                if (math_umathcode_meaning_par == 1) {
                     cur_val = (mval.class_value + (8 * mval.family_value)) * (65536 * 32) + mval.character_value;
                     define(p, xmath_given_cmd, cur_val);
                 } else {
@@ -2462,42 +2424,78 @@ void prefixed_command(void)
             /* DIR: Assign direction codes */
             scan_direction();
             switch (cur_chr) {
-            case int_base + page_direction_code:
-                eq_word_define(int_base + page_direction_code, cur_val);
-                break;
-            case int_base + body_direction_code:
-                eq_word_define(int_base + body_direction_code, cur_val);
-                break;
-            case int_base + par_direction_code:
-                eq_word_define(int_base + par_direction_code, cur_val);
-                break;
-            case int_base + math_direction_code:
-                eq_word_define(int_base + math_direction_code, cur_val);
-                break;
-            case int_base + text_direction_code:
-#if 0
-    /* various tests hint that this is unnecessary and
-     * sometimes even produces weird results, eg
-     *  (\hbox{\textdir TRT ABC\textdir TLT DEF})
-     * becomes
-     *  (DEFCBA)
-     * in the output
-     */
-                if ((no_local_dirs > 0) && (abs(mode) == hmode)) {
-                    /* DIR: Add local dir node */
-                    tail_append(new_dir(text_direction));
-                }
-#endif
-                update_text_dir_ptr(cur_val);
-                if (abs(mode) == hmode) {
-                    /* DIR: Add local dir node */
-                    tail_append(new_dir(cur_val));
-                    dir_level(tail) = cur_level;
+                case int_base + page_direction_code:
+                    eq_word_define(int_base + page_direction_code, cur_val);
+                    break;
+                case int_base + body_direction_code:
+                    eq_word_define(int_base + body_direction_code, cur_val);
+                    break;
+                case int_base + par_direction_code:
+                    eq_word_define(int_base + par_direction_code, cur_val);
+                    break;
+                case int_base + math_direction_code:
+                    eq_word_define(int_base + math_direction_code, cur_val);
+                    break;
+                case int_base + text_direction_code:
+                case int_base + line_direction_code:
+                    /*
+                        pre version 0.97 this was a commented section because various tests hint that this
+                        is unnecessary and sometimes even produces weird results, like:
+
+                            (\hbox{\textdir TRT ABC\textdir TLT DEF}))
+
+                        becomes
+
+                            (DEFCBA)
+
+                        in the output when we use
+
+                            tail_append(new_dir(text_direction_par)
+
+                        but when we append the reverse of the current it goes better
+
+                    */
+                    check_glue = (cur_chr == (int_base + line_direction_code));
+                    if (check_glue) {
+                        cur_chr = int_base + text_direction_code ;
+                    }
+                    if (abs(mode) == hmode) {
+                        if (no_local_dirs_par > 0) {
+                            /* tail is non zero but we test anyway */
+                            if (check_glue && (tail != null && type(tail) == glue_node))  {
+                                halfword prev = alink(tail);
+                                halfword dirn = new_dir(text_direction_par - dir_swap);
+                                couple_nodes(prev,dirn);
+                                couple_nodes(dirn,tail);
+                            } else {
+                                tail_append(new_dir(text_direction_par - dir_swap));
+                            }
+                        } else {
+                            /* what is the use of nolocaldirs .. maybe we should get rid of it */
+                        }
+                        update_text_dir_ptr(cur_val);
+                        tail_append(new_dir(cur_val));
+                        dir_level(tail) = cur_level;
+                    } else {
+                        update_text_dir_ptr(cur_val);
+                    }
+                    /*  original:
+
+                        // if ((no_local_dirs_par > 0) && (abs(mode) == hmode)) {
+                        //  // tail_append(new_dir(text_direction_par)              // kind of wrong
+                        //     tail_append(new_dir(text_direction_par - dir_swap)); // better
+                        // }
+
+                        update_text_dir_ptr(cur_val);
+                        if (abs(mode) == hmode) {
+                            tail_append(new_dir(cur_val));
+                            dir_level(tail) = cur_level;
+                        }
+                    */
+                    eq_word_define(int_base + text_direction_code, cur_val);
+                    eq_word_define(int_base + no_local_dirs_code, no_local_dirs_par + 1);
+                    break;
                 }
-                eq_word_define(int_base + text_direction_code, cur_val);
-                eq_word_define(int_base + no_local_dirs_code, no_local_dirs + 1);
-                break;
-            }
             break;
         case assign_dimen_cmd:
             p = cur_chr;
@@ -2612,11 +2610,11 @@ void prefixed_command(void)
                     scan_dimen(false, false, false);
             } else {
                 scan_glue(mu_val_level);
-                if (cur_val == glue_par(thin_mu_skip_code))
+                if (cur_val == thin_mu_skip_par)
                     cur_val = thin_mu_skip_code;
-                else if (cur_val == glue_par(med_mu_skip_code))
+                else if (cur_val == med_mu_skip_par)
                     cur_val = med_mu_skip_code;
-                else if (cur_val == glue_par(thick_mu_skip_code))
+                else if (cur_val == thick_mu_skip_par)
                     cur_val = thick_mu_skip_code;
             }
             define_math_param(p, cur_val1, cur_val);
@@ -2810,9 +2808,9 @@ void prefixed_command(void)
 @ @c
 void fixup_directions(void)
 {
-    int temp_no_whatsits = no_local_whatsits;
-    int temp_no_dirs = no_local_dirs;
-    int temporary_dir = text_direction;
+    int temp_no_whatsits = no_local_whatsits_par;
+    int temp_no_dirs = no_local_dirs_par;
+    int temporary_dir = text_direction_par;
     if (dir_level(text_dir_ptr) == cur_level) {
         /* DIR: Remove from |text_dir_ptr| */
         halfword text_dir_tmp = vlink(text_dir_ptr);
@@ -2823,7 +2821,7 @@ void fixup_directions(void)
     if (abs(mode) == hmode) {
         if (temp_no_dirs != 0) {
             /* DIR: Add local dir node */
-            tail_append(new_dir(text_direction));
+            tail_append(new_dir(text_direction_par));
             dir_dir(tail) = temporary_dir - dir_swap;
         }
         if (temp_no_whatsits != 0) {
@@ -2868,7 +2866,7 @@ void assign_internal_value(int a, halfword p, int val)
         switch ((p - int_base)) {
         case cat_code_table_code:
             if (valid_catcode_table(val)) {
-                if (val != int_par(cat_code_table_code))
+                if (val != cat_code_table_par)
                     word_define(p, val);
             } else {
                 print_err("Invalid \\catcode table");
@@ -2939,9 +2937,7 @@ void assign_internal_value(int a, halfword p, int val)
              (p == (int_base + local_broken_penalty_code)))) {
             /* LOCAL: Add local paragraph node */
             tail_append(make_local_par_node(penalty_par_code));
-
-            eq_word_define(int_base + no_local_whatsits_code,
-                           no_local_whatsits + 1);
+            eq_word_define(int_base + no_local_whatsits_code, no_local_whatsits_par + 1);
         }
     } else if ((p >= dimen_base) && (p <= eqtb_size)) {
         if (p == (dimen_base + page_left_offset_code)) {
@@ -3115,7 +3111,7 @@ void alter_aux(void)
         scan_optional_equals();
         if (c == vmode) {
             scan_normal_dimen();
-            prev_depth = cur_val;
+            prev_depth_par = cur_val;
         } else {
             scan_int();
             if ((cur_val <= 0) || (cur_val > 32767)) {
@@ -3123,7 +3119,7 @@ void alter_aux(void)
                 help1("I allow only values in the range 1..32767 here.");
                 int_error(cur_val);
             } else {
-                space_factor = cur_val;
+                space_factor_par = cur_val;
             }
         }
     }
@@ -3299,7 +3295,7 @@ void issue_message(void)
            give a verbose explanation only once. */
         print_err("");
         print(s);
-        if (err_help != null) {
+        if (err_help_par != null) {
             use_err_help = true;
         } else if (long_help_seen) {
             help1("(That was another \\errmessage.)");
@@ -3324,7 +3320,7 @@ the |err_help| parameter.
 @c
 void give_err_help(void)
 {
-    token_show(err_help);
+    token_show(err_help_par);
 }
 
 @ The \.{\\uppercase} and \.{\\lowercase} commands are implemented by
@@ -3467,7 +3463,7 @@ void show_whatever(void)
     end_diagnostic(true);
     print_err("OK");
     if (selector == term_and_log) {
-        if (tracing_online <= 0) {
+        if (tracing_online_par <= 0) {
             selector = term_only;
             tprint(" (see the transcript file)");
             selector = term_and_log;
@@ -3477,7 +3473,7 @@ void show_whatever(void)
     if (interaction < error_stop_mode) {
         help0();
         decr(error_count);
-    } else if (tracing_online > 0) {
+    } else if (tracing_online_par > 0) {
         help3("This isn't an error message; I'm just \\showing something.",
               "Type `I\\show...' to show more (e.g., \\show\\cs,",
               "\\showthe\\count10, \\showbox255, \\showlists).");
@@ -3558,7 +3554,7 @@ void initialize(void)
         for (k = glue_base + 1; k <= local_base - 1; k++) {
             eqtb[k] = eqtb[glue_base];
         }
-        par_shape_ptr = null;
+        par_shape_par_ptr = null;
         set_eq_type(par_shape_loc, shape_ref_cmd);
         set_eq_level(par_shape_loc, level_one);
         for (k = etex_pen_base; k <= (etex_pens - 1); k++)
@@ -3570,7 +3566,7 @@ void initialize(void)
         set_eq_level(box_base, level_one);
         for (k = box_base + 1; k <= (box_base + biggest_reg); k++)
             eqtb[k] = eqtb[box_base];
-        cur_font = null_font;
+        cur_font_par = null_font;
         set_eq_type(cur_font_loc, data_cmd);
         set_eq_level(cur_font_loc, level_one);
         set_equiv(cat_code_base, 0);
@@ -3581,7 +3577,7 @@ void initialize(void)
         eqtb[uc_code_base] = eqtb[cat_code_base];
         eqtb[sf_code_base] = eqtb[cat_code_base];
         eqtb[math_code_base] = eqtb[cat_code_base];
-        cat_code_table = 0;
+        cat_code_table_par = 0;
         initialize_math_codes();
         initialize_text_codes();
         initex_cat_codes(0);
@@ -3600,21 +3596,21 @@ void initialize(void)
             eqtb[k].cint = 0;
         for (k = attribute_base; k <= del_code_base - 1; k++)
             eqtb[k].cint = UNUSED_ATTRIBUTE;
-        mag = 1000;
-        tolerance = 10000;
-        hang_after = 1;
-        max_dead_cycles = 25;
-        escape_char = '\\';
-        end_line_char = carriage_return;
+        mag_par = 1000;
+        tolerance_par = 10000;
+        hang_after_par = 1;
+        max_dead_cycles_par = 25;
+        escape_char_par = '\\';
+        end_line_char_par = carriage_return;
         set_del_code('.', 0, 0, 0, 0, level_one); /* this null delimiter is used in error recovery */
-        ex_hyphen_char = '-';
-        output_box = 255;
+        ex_hyphen_char_par = '-';
+        output_box_par = 255;
         for (k = dimen_base; k <= eqtb_size; k++)
             eqtb[k].cint = 0;
-        page_left_offset = one_inch;
-        page_top_offset = one_inch;
-        page_right_offset = one_inch;
-        page_bottom_offset = one_inch;
+        page_left_offset_par = one_inch;
+        page_top_offset_par = one_inch;
+        page_right_offset_par = one_inch;
+        page_bottom_offset_par = one_inch;
         ini_init_primitives();
         hash_used = frozen_control_sequence;    /* nothing is used */
         hash_high = 0;
@@ -3627,8 +3623,8 @@ void initialize(void)
         cs_text(frozen_primitive) = maketexstring("primitive");
         create_null_font();
         font_bytes = 0;
-        px_dimen = one_bp;
-        math_eqno_gap_step = 1000 ;
+        px_dimen_par = one_bp;
+        math_eqno_gap_step_par = 1000 ;
         cs_text(frozen_protection) = maketexstring("inaccessible");
         format_ident = maketexstring(" (INITEX)");
         cs_text(end_write) = maketexstring("endwrite");
diff --git a/source/texk/web2c/luatexdir/tex/mathcodes.w b/source/texk/web2c/luatexdir/tex/mathcodes.w
index 64efce9d8980b043253b21910e05457af2fe63b3..8c0760ae51e3fab0fde8e0640c6bacc44b119ea6 100644
--- a/source/texk/web2c/luatexdir/tex/mathcodes.w
+++ b/source/texk/web2c/luatexdir/tex/mathcodes.w
@@ -124,7 +124,7 @@ static void unsavemathcode(quarterword gl)
         st = mathcode_head->stack[mathcode_head->stack_ptr];
         if (st.level > 0) {
             rawset_sa_item(mathcode_head, st.code, st.value);
-            if (int_par(tracing_restores_code) > 1) {
+            if (tracing_restores_par > 1) {
                 begin_diagnostic();
                 print_char('{');
                 tprint("restoring");
@@ -150,7 +150,7 @@ void set_math_code(int n, int mathclass, int mathfamily, int mathcharacter, quar
         v.math_code_value.character_value = mathcharacter;
     }
     set_sa_item(mathcode_head, n, v, level);
-    if (int_par(tracing_assigns_code) > 1) {
+    if (tracing_assigns_par > 1) {
         begin_diagnostic();
         print_char('{');
         tprint("assigning");
@@ -242,7 +242,7 @@ static void unsavedelcode(quarterword gl)
         st = delcode_head->stack[delcode_head->stack_ptr];
         if (st.level > 0) {
             rawset_sa_item(delcode_head, st.code, st.value);
-            if (int_par(tracing_restores_code) > 1) {
+            if (tracing_restores_par > 1) {
                 begin_diagnostic();
                 print_char('{');
                 tprint("restoring");
@@ -267,7 +267,7 @@ void set_del_code(int n, int smathfamily, int smathcharacter, int lmathfamily, i
     v.del_code_value.large_family_value = lmathfamily;
     v.del_code_value.large_character_value = lmathcharacter;
     set_sa_item(delcode_head, n, v, gl); /* always global */
-    if (int_par(tracing_assigns_code) > 1) {
+    if (tracing_assigns_par > 1) {
         begin_diagnostic();
         print_char('{');
         tprint("assigning");
diff --git a/source/texk/web2c/luatexdir/tex/mlist.w b/source/texk/web2c/luatexdir/tex/mlist.w
index bceb4e88ad1cdd152c87619335cbc66f327b65aa..331be47de7dc01c9a6e1d4a7e34ffc78895a3bd4 100644
--- a/source/texk/web2c/luatexdir/tex/mlist.w
+++ b/source/texk/web2c/luatexdir/tex/mlist.w
@@ -51,12 +51,7 @@ to italics. Axis are another area of concern, as it looks like opentype math fon
 already apply that shift.
 
 @ @c
-#define math_old                      mathoption_int_par(c_mathoption_old_code)
-#define math_no_italic_compensation   mathoption_int_par(c_mathoption_no_italic_compensation_code)
-#define math_no_char_italic           mathoption_int_par(c_mathoption_no_char_italic_code)
-#define math_use_old_fraction_scaling mathoption_int_par(c_mathoption_use_old_fraction_scaling_code)
-
-#define is_new_mathfont(A)   ((font_math_params(A) >0) && (math_old == 0))
+#define is_new_mathfont(A)   ((font_math_params(A) >0) && (math_old_par == 0))
 #define is_old_mathfont(A,B) ((font_math_params(A)==0) && (font_params(A)>=(B)))
 
 @
@@ -68,17 +63,6 @@ already apply that shift.
 #include "lua/luatex-api.h"
 
 @ @c
-#define delimiter_factor     int_par(delimiter_factor_code)
-#define delimiter_shortfall  dimen_par(delimiter_shortfall_code)
-#define bin_op_penalty       int_par(bin_op_penalty_code)
-#define rel_penalty          int_par(rel_penalty_code)
-#define null_delimiter_space dimen_par(null_delimiter_space_code)
-#define script_space         dimen_par(script_space_code)
-#define disable_lig          int_par(disable_lig_code)
-#define disable_kern         int_par(disable_kern_code)
-#define disable_space        int_par(disable_space_code)
-#define scripts_mode         int_par(math_scripts_mode_code)
-
 #define nDEBUG
 
 #define reset_attributes(p,newatt) do {                \
@@ -322,8 +306,8 @@ static scaled get_delimiter_height(scaled max_d, scaled max_h, boolean axis) {
         /* |delta1| is max distance from axis */
         delta1 = delta2;
     }
-    delta = (delta1 / 500) * delimiter_factor;
-    delta2 = delta1 + delta1 - delimiter_shortfall;
+    delta = (delta1 / 500) * delimiter_factor_par;
+    delta2 = delta1 + delta1 - delimiter_shortfall_par;
     if (delta < delta2) {
         return delta2;
     } else {
@@ -884,27 +868,27 @@ backward compatibility with \.{\\scriptspace}.
 @c
 static void finalize_math_parameters(void)
 {
-    int saved_trace = int_par(tracing_assigns_code);
-    int_par(tracing_assigns_code) = 0;
+    int saved_trace = tracing_assigns_par;
+    tracing_assigns_par = 0;
     if (get_math_param(math_param_space_after_script, display_style) == undefined_math_parameter) {
         def_math_param(math_param_space_after_script, display_style,
-            script_space, level_one);
+            script_space_par, level_one);
         def_math_param(math_param_space_after_script, text_style,
-            script_space, level_one);
+            script_space_par, level_one);
         def_math_param(math_param_space_after_script, script_style,
-            script_space, level_one);
+            script_space_par, level_one);
         def_math_param(math_param_space_after_script, script_script_style,
-            script_space, level_one);
+            script_space_par, level_one);
         def_math_param(math_param_space_after_script, cramped_display_style,
-            script_space, level_one);
+            script_space_par, level_one);
         def_math_param(math_param_space_after_script, cramped_text_style,
-            script_space, level_one);
+            script_space_par, level_one);
         def_math_param(math_param_space_after_script, cramped_script_style,
-            script_space, level_one);
+            script_space_par, level_one);
         def_math_param(math_param_space_after_script, cramped_script_script_style,
-            script_space, level_one);
+            script_space_par, level_one);
     }
-    int_par(tracing_assigns_code) = saved_trace;
+    tracing_assigns_par = saved_trace;
 }
 
 @ In order to convert mlists to hlists, i.e., noads to nodes, we need several
@@ -968,7 +952,7 @@ static pointer do_fraction_rule(scaled t, pointer att)
 {
     pointer p;                  /* the new node */
     p = new_rule(normal_rule);
-    rule_dir(p) = math_direction;
+    rule_dir(p) = math_direction_par;
     height(p) = t;
     depth(p) = 0;
     reset_attributes(p, att);
@@ -991,7 +975,7 @@ static pointer overbar(pointer b, scaled k, scaled t, scaled ht, pointer att)
     p = new_kern(ht);
     reset_attributes(p, att);
     couple_nodes(p,q);
-    q = vpackage(p, 0, additional, max_dimen, math_direction);
+    q = vpackage(p, 0, additional, max_dimen, math_direction_par);
     reset_attributes(q, att);
     return q;
 }
@@ -1134,7 +1118,7 @@ static pointer get_delim_box(pointer q, extinfo * ext, internal_font_number f, s
                 NULL
             };
             tex_error("Variant part doesn't exist.", hlp);
-            width(b) = null_delimiter_space;
+            width(b) = null_delimiter_space_par;
             return b;
         }
         if (cur->extender > 0)
@@ -1447,7 +1431,7 @@ static pointer do_delimiter(pointer q, pointer d, int s, scaled v, boolean flat,
             width(b) = 0;
         } else {
             /* use this width if no delimiter was found */
-            width(b) = null_delimiter_space;
+            width(b) = null_delimiter_space_par;
         }
         if (delta != NULL) {
             *delta = 0;
@@ -1595,7 +1579,6 @@ void run_mlist_to_hlist(halfword p, boolean penalties, int mstyle)
 {
     int callback_id;
     int a, sfix;
-    lua_State *L = Luas;
     if (p == null) {
         vlink(temp_head) = null;
         return;
@@ -1603,26 +1586,26 @@ void run_mlist_to_hlist(halfword p, boolean penalties, int mstyle)
     finalize_math_parameters();
     callback_id = callback_defined(mlist_to_hlist_callback);
     if (callback_id > 0) {
-        sfix = lua_gettop(L);
-        if (!get_callback(L, callback_id)) {
-            lua_settop(L, sfix);
+        sfix = lua_gettop(Luas);
+        if (!get_callback(Luas, callback_id)) {
+            lua_settop(Luas, sfix);
             return;
         }
         alink(p) = null ;
-        nodelist_to_lua(L, p);
-        lua_push_math_style_name(L,mstyle);
-        lua_pushboolean(L, penalties);
-        if (lua_pcall(L, 3, 1, 0) != 0) {            /* 3 args, 1 result */
+        nodelist_to_lua(Luas, p);
+        lua_push_math_style_name(Luas, mstyle);
+        lua_pushboolean(Luas, penalties);
+        if (lua_pcall(Luas, 3, 1, 0) != 0) {            /* 3 args, 1 result */
             char errmsg[256]; /* temp hack ... we will have a formatted error */
-            snprintf(errmsg, 255, "error: %s\n", lua_tostring(L, -1));
+            snprintf(errmsg, 255, "error: %s\n", lua_tostring(Luas, -1));
             errmsg[255]='\0';
-            lua_settop(L, sfix);
+            lua_settop(Luas, sfix);
             normal_error("mlist to hlist",errmsg); /* to be done */
             return;
         }
-        a = nodelist_from_lua(L);
+        a = nodelist_from_lua(Luas);
         /* alink(vlink(a)) = null; */
-        lua_settop(L, sfix);
+        lua_settop(Luas, sfix);
         vlink(temp_head) = a;
     } else if (callback_id == 0) {
         mlist_to_hlist(p, penalties, mstyle);
@@ -1803,7 +1786,7 @@ static void make_under(pointer q, int cur_style)
     couple_nodes(x,p);
     r = do_fraction_rule(underbar_rule(cur_style), node_attr(q));
     couple_nodes(p,r);
-    y = vpackage(x, 0, additional, max_dimen, math_direction);
+    y = vpackage(x, 0, additional, max_dimen, math_direction_par);
     reset_attributes(y, node_attr(q));
     delta = height(y) + depth(y) + underbar_kern(cur_style);
     height(y) = height(x);
@@ -2304,7 +2287,7 @@ static void do_make_math_accent(pointer q, internal_font_number f, int c, int fl
             /* just take the center */
             sa = half(width(y));
         }
-        if (math_direction == dir_TRT) {
+        if (math_direction_par == dir_TRT) {
            shift_amount(y) = s + sa - width(y);
         } else {
            shift_amount(y) = s - sa;
@@ -2312,7 +2295,7 @@ static void do_make_math_accent(pointer q, internal_font_number f, int c, int fl
     } else {
         if (width(y)== 0) {
             shift_amount(y) = s + w;
-        } else if (math_direction == dir_TRT) {
+        } else if (math_direction_par == dir_TRT) {
             shift_amount(y) = s + width(y); /* ok? */
         } else {
             shift_amount(y) = s + half(w - width(y));
@@ -2328,7 +2311,7 @@ static void do_make_math_accent(pointer q, internal_font_number f, int c, int fl
         couple_nodes(x,y);
         y = x;
     }
-    r = vpackage(y, 0, additional, max_dimen, math_direction);
+    r = vpackage(y, 0, additional, max_dimen, math_direction_par);
     reset_attributes(r, node_attr(q));
     width(r) = width(x);
     y = r;
@@ -2564,7 +2547,7 @@ static void make_fraction(pointer q, int cur_style)
         point to it
     */
     if (is_new_mathfont(cur_f)) {
-        if (math_use_old_fraction_scaling) {
+        if (math_use_old_fraction_scaling_par) {
             delta = fraction_del_size_old(cur_style);
         } else {
             delta = fraction_del_size_new(cur_style);
@@ -2711,7 +2694,7 @@ static scaled make_op(pointer q, int cur_style)
         type(v) = vlist_node;
         if (is_new_mathfont(cur_f)) {
             n = null;
-            if (! math_no_italic_compensation) {
+            if (! math_no_italic_compensation_par) {
                 n = nucleus(q);
                 if (n != null) {
                     if ((type(n) == sub_mlist_node) || (type(n) == sub_box_node)) {
@@ -2885,7 +2868,7 @@ static void make_ord(pointer q)
                     ligatures only when this convention makes sense
                 */
 
-                if (disable_lig == 0 && has_lig(cur_f, a)) {
+                if (disable_lig_par == 0 && has_lig(cur_f, a)) {
                     lig = get_ligature(cur_f, a, cur_c);
                     if (is_valid_ligature(lig)) {
                         check_interrupt();      /* allow a way out of infinite ligature loop */
@@ -2941,7 +2924,7 @@ static void make_ord(pointer q)
                         goto RESTART;
                     }
                 }
-                if (disable_kern == 0 && has_kern(cur_f, a)) {
+                if (disable_kern_par == 0 && has_kern(cur_f, a)) {
                     /* todo: should this use mathkerns? */
                     k = get_kern(cur_f, a, cur_c);
                     if (k != 0) {
@@ -3239,7 +3222,7 @@ static void make_scripts(pointer q, pointer p, scaled it, int cur_style, scaled
         */
         x = clean_box(subscr(q), sub_style(cur_style), cur_style);
         width(x) = width(x) + space_after_script(cur_style);
-        switch (scripts_mode) {
+        switch (scripts_mode_par) {
             case 1:
                 shift_down = sub_shift_down(cur_style) ;
                 break;
@@ -3289,7 +3272,7 @@ static void make_scripts(pointer q, pointer p, scaled it, int cur_style, scaled
         */
         x = clean_box(supscr(q), sup_style(cur_style), cur_style);
         width(x) = width(x) + space_after_script(cur_style);
-        switch (scripts_mode) {
+        switch (scripts_mode_par) {
             case 1:
                 shift_up = sup_shift_up(cur_style);
                 break;
@@ -3344,7 +3327,7 @@ static void make_scripts(pointer q, pointer p, scaled it, int cur_style, scaled
             */
             y = clean_box(subscr(q), sub_style(cur_style), cur_style);
             width(y) = width(y) + space_after_script(cur_style);
-            switch (scripts_mode) {
+            switch (scripts_mode_par) {
                 case 1:
                     shift_down = sub_shift_down(cur_style) ;
                     break;
@@ -3413,7 +3396,7 @@ static void make_scripts(pointer q, pointer p, scaled it, int cur_style, scaled
             couple_nodes(x,p);
             couple_nodes(p,y);
             /* we end up with funny dimensions */
-            x = vpackage(x, 0, additional, max_dimen, math_direction);
+            x = vpackage(x, 0, additional, max_dimen, math_direction_par);
             reset_attributes(x, node_attr(q));
             shift_amount(x) = shift_down;
         }
@@ -3758,7 +3741,7 @@ static pointer check_nucleus_complexity(halfword q, scaled * delta, int cur_styl
             p = new_glyph(cur_f, cur_c);
             reset_attributes(p, node_attr(nucleus(q)));
             if (is_new_mathfont(cur_f)) {
-                if (! math_no_char_italic) {
+                if (! math_no_char_italic_par) {
                     /* keep italic, but bad with two successive letters */
                 } else if (get_char_cat_code(cur_c) == 11) {
                     /* no italic correction in mid-word of text font */
@@ -4087,10 +4070,10 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
             t_subtype = subtype(q);
             switch (t_subtype) {
             case bin_noad_type:
-                pen = bin_op_penalty;
+                pen = bin_op_penalty_par;
                 break;
             case rel_noad_type:
-                pen = rel_penalty;
+                pen = rel_penalty_par;
                 break;
             case vcenter_noad_type:
             case over_noad_type:
diff --git a/source/texk/web2c/luatexdir/tex/nesting.w b/source/texk/web2c/luatexdir/tex/nesting.w
index 045bf78febe4f0640d67b0960332a6b9c7c8b495..d9e7cf744ee799f1924201f3195768ede2733bdc 100644
--- a/source/texk/web2c/luatexdir/tex/nesting.w
+++ b/source/texk/web2c/luatexdir/tex/nesting.w
@@ -19,14 +19,11 @@
 
 @ @c
 
-
 #include "ptexlib.h"
 
 @ these are for |show_activities|
 @c
 #define page_goal page_so_far[0]
-#define count(A) eqtb[count_base+(A)].cint
-
 
 @ \TeX\ is typically in the midst of building many lists at once. For example,
 when a math formula is being processed, \TeX\ is in math mode and
@@ -251,9 +248,7 @@ void initialize_nesting(void)
     init_math_fields();
 }
 
-
-
-@ Here is a common way to make the current list grow: 
+@ Here is a common way to make the current list grow:
 
 @c
 void tail_append(halfword p)
@@ -262,7 +257,6 @@ void tail_append(halfword p)
     cur_list.tail_field = vlink(cur_list.tail_field);
 }
 
-
 @ @c
 halfword pop_tail(void)
 {
@@ -311,7 +305,6 @@ void push_nest(void)
     init_math_fields();
 }
 
-
 @ Conversely, when \TeX\ is finished on the current level, the former
 state is restored by calling |pop_nest|. This routine will never be
 called at the lowest semantic level, nor will it be called unless |head|
@@ -324,7 +317,7 @@ void pop_nest(void)
     decr(nest_ptr);
 }
 
-@ Here is a procedure that displays what \TeX\ is working on, at all levels. 
+@ Here is a procedure that displays what \TeX\ is working on, at all levels.
 
 @c
 void show_activities(void)
@@ -343,7 +336,7 @@ void show_activities(void)
         print_int(abs(nest[p].ml_field));
         /* we dont do this any more */
 #if 0
-        
+
            if (m == hmode)
            if (nest[p].pg_field != 040600000) {
            tprint(" (language");
diff --git a/source/texk/web2c/luatexdir/tex/packaging.w b/source/texk/web2c/luatexdir/tex/packaging.w
index e722791b28bfbc3336d9512b59183d44b7b8c015..ba0a5d764acd80136e43d125cd868a404f4b75c9 100644
--- a/source/texk/web2c/luatexdir/tex/packaging.w
+++ b/source/texk/web2c/luatexdir/tex/packaging.w
@@ -21,17 +21,6 @@
 
 #include "ptexlib.h"
 
-@ @c
-#define scan_normal_dimen() scan_dimen(false,false,false)
-
-#define prev_depth      cur_list.prev_depth_field
-#define space_factor    cur_list.space_factor_field
-#define box(A) eqtb[box_base+(A)].hh.rh
-
-#define every_hbox equiv(every_hbox_loc)
-#define every_vbox equiv(every_vbox_loc)
-#define box_max_depth dimen_par(box_max_depth_code)
-
 @ We're essentially done with the parts of \TeX\ that are concerned with the
 input (|get_next|) and the output (|ship_out|). So it's time to get heavily into
 the remaining part, which does the real work of typesetting.
@@ -286,7 +275,7 @@ void scan_full_spec(group_code c, int spec_direction, int just_pack)
     if (! done) {
         scan_left_brace();
     }
-    /* no gain: if (body_direction != spec_direction) etc */
+    /* no gain: if (body_direction_par != spec_direction) etc */
     eq_word_define(int_base + body_direction_code, spec_direction);
     eq_word_define(int_base + par_direction_code, spec_direction);
     eq_word_define(int_base + text_direction_code, spec_direction);
@@ -632,7 +621,7 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction)
     halfword pack_interrupt[8];
     scaled font_stretch = 0;
     scaled font_shrink = 0;
-    int adjust_spacing = int_par(adjust_spacing_code);
+    int adjust_spacing = adjust_spacing_par;
 
 /*
     int font_expand_ratio = 0;
@@ -640,7 +629,7 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction)
     last_badness = 0;
     r = new_node(hlist_node, min_quarterword); /* the box node that will be returned */
     if (pack_direction == -1) {
-        hpack_dir = text_direction;
+        hpack_dir = text_direction_par;
     } else {
         hpack_dir = pack_direction;
     }
@@ -943,7 +932,7 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction)
                     is sufficiently bad.
                 */
                 last_badness = badness(x, total_stretch[normal]);
-                if (last_badness > int_par(hbadness_code)) {
+                if (last_badness > hbadness_par) {
                     int callback_id = callback_defined(hpack_quality_callback);
                     if (callback_id > 0) {
                         halfword rule = null;
@@ -1010,15 +999,15 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction)
                 Report an overfull hbox and |goto common_ending|, if this box
                 is sufficiently bad.
             */
-            if ((overshoot > dimen_par(hfuzz_code)) || (int_par(hbadness_code) < 100)) {
+            if ((overshoot > hfuzz_par) || (hbadness_par < 100)) {
                 int callback_id = callback_defined(hpack_quality_callback);
                 halfword rule = null;
                 if (callback_id > 0) {
                     run_callback(callback_id, "SdNdd->N","overfull",overshoot,r,abs(pack_begin_line),line,&rule);
-                } else if (dimen_par(overfull_rule_code) > 0) {
+                } else if (overfull_rule_par > 0) {
                     rule = new_rule(normal_rule);
                     rule_dir(rule) = box_dir(r);
-                    width(rule) = dimen_par(overfull_rule_code);
+                    width(rule) = overfull_rule_par;
                 }
                 if (rule != null) {
                     while (vlink(q) != null) {
@@ -1041,7 +1030,7 @@ halfword hpack(halfword p, scaled w, int m, int pack_direction)
                     sufficiently bad.
                 */
                 last_badness = badness(-x, total_shrink[normal]);
-                if (last_badness > int_par(hbadness_code)) {
+                if (last_badness > hbadness_par) {
                     int callback_id = callback_defined(hpack_quality_callback);
                     if (callback_id > 0) {
                         halfword rule = null;
@@ -1119,7 +1108,7 @@ halfword filtered_hpack(halfword p, halfword qt, scaled w, int m, int grp, int p
         q = vlink(p);
         /*
             q = new_node(hlist_node, min_quarterword);
-            box_dir(q) = (pac == -1) ? text_direction : pac;
+            box_dir(q) = (pac == -1) ? text_direction_par : pac;
             width(q) = w;
             return q;
         */
@@ -1147,7 +1136,7 @@ scaled_whd natural_sizes(halfword p, halfword pp, glue_ratio g_mult,
     scaled gp = 0;
     scaled gm = 0;
     if (pack_direction == -1) {
-        hpack_dir = text_direction;
+        hpack_dir = text_direction_par;
     } else {
         hpack_dir = pack_direction;
     }
@@ -1292,7 +1281,7 @@ halfword vpackage(halfword p, scaled h, int m, scaled l, int pack_direction)
     last_badness = 0;
     r = new_node(vlist_node, 0);
     if (pack_direction == -1) {
-        box_dir(r) = body_direction;
+        box_dir(r) = body_direction_par;
     } else {
         box_dir(r) = pack_direction;
     }
@@ -1434,7 +1423,7 @@ halfword vpackage(halfword p, scaled h, int m, scaled l, int pack_direction)
                     is sufficiently bad.
                 */
                 last_badness = badness(x, total_stretch[normal]);
-                if (last_badness > int_par(vbadness_code)) {
+                if (last_badness > vbadness_par) {
                     int callback_id = callback_defined(vpack_quality_callback);
                     if (callback_id > 0) {
                         if (last_badness > 100) {
@@ -1492,7 +1481,7 @@ halfword vpackage(halfword p, scaled h, int m, scaled l, int pack_direction)
                 Report an overfull vbox and |goto common_ending|, if this box
                 is sufficiently bad.
             */
-            if ((overshoot > dimen_par(vfuzz_code)) || (int_par(vbadness_code) < 100)) {
+            if ((overshoot > vfuzz_par) || (vbadness_par < 100)) {
                 int callback_id = callback_defined(vpack_quality_callback);
                 if (callback_id > 0) {
                     run_callback(callback_id, "SdNdd->","overfull",overshoot,r,abs(pack_begin_line),line);
@@ -1512,7 +1501,7 @@ halfword vpackage(halfword p, scaled h, int m, scaled l, int pack_direction)
                     sufficiently bad.
                 */
                 last_badness = badness(-x, total_shrink[normal]);
-                if (last_badness > int_par(vbadness_code)) {
+                if (last_badness > vbadness_par) {
                     int callback_id = callback_defined(vpack_quality_callback);
                     if (callback_id > 0) {
                         run_callback(callback_id, "SdNdd->","tight",last_badness,r,abs(pack_begin_line),line);
@@ -1579,7 +1568,7 @@ void package(int c)
 {
     halfword saved0, saved2, saved3, saved4;
     int grp = cur_group;
-    scaled d = box_max_depth; /* max depth */
+    scaled d = box_max_depth_par; /* max depth */
     unsave();
     save_ptr -= 5;
     saved0 = saved_value(0);
@@ -1633,23 +1622,23 @@ void append_to_vlist(halfword b, int location)
     halfword result = null;
     halfword next_depth = ignore_depth;
     boolean prev_set = false ;
-    if (lua_appendtovlist_callback(b,location,prev_depth,mirrored,&result,&next_depth,&prev_set)) {
+    if (lua_appendtovlist_callback(b,location,prev_depth_par,mirrored,&result,&next_depth,&prev_set)) {
         while (result != null) {
             couple_nodes(cur_list.tail_field, result);
             cur_list.tail_field = result;
             result = vlink(result);
         }
         if (prev_set) {
-            prev_depth = next_depth;
+            prev_depth_par = next_depth;
         }
     } else {
-        if (prev_depth > ignore_depth) {
+        if (prev_depth_par > ignore_depth) {
             if (mirrored) {
-                d = width(glue_par(baseline_skip_code)) - prev_depth - depth(b);
+                d = width(baseline_skip_par) - prev_depth_par - depth(b);
             } else {
-                d = width(glue_par(baseline_skip_code)) - prev_depth - height(b);
+                d = width(baseline_skip_par) - prev_depth_par - height(b);
             }
-            if (d < dimen_par(line_skip_limit_code)) {
+            if (d < line_skip_limit_par) {
                 p = new_param_glue(line_skip_code);
             } else {
                 p = new_skip_param(baseline_skip_code);
@@ -1661,9 +1650,9 @@ void append_to_vlist(halfword b, int location)
         couple_nodes(cur_list.tail_field, b);
         cur_list.tail_field = b;
         if (mirrored) {
-            prev_depth = height(b);
+            prev_depth_par = height(b);
         } else {
-            prev_depth = depth(b);
+            prev_depth_par = depth(b);
         }
     }
 }
@@ -1959,7 +1948,7 @@ halfword vsplit(halfword n, scaled h, int m)
         error();
         return null;
     }
-    q = vert_break(list_ptr(v), h, dimen_par(split_max_depth_code));
+    q = vert_break(list_ptr(v), h, split_max_depth_par);
     /*
         Look at all the marks in nodes before the break, and set the final
         link to |null| at the break. It's possible that the box begins with
@@ -1990,7 +1979,7 @@ halfword vsplit(halfword n, scaled h, int m)
             p = vlink(p);
         }
     }
-    q = prune_page_top(q, int_par(saving_vdiscards_code) > 0);
+    q = prune_page_top(q, saving_vdiscards_par > 0);
     p = list_ptr(v);
     list_ptr(v) = null;
     flush_node(v);
@@ -1998,12 +1987,12 @@ halfword vsplit(halfword n, scaled h, int m)
         /* the |eq_level| of the box stays the same */
         box(n) = null;
     } else {
-        box(n) = filtered_vpackage(q, 0, additional, dimen_par(max_depth_code), split_keep_group, vdir, 0, 0);
+        box(n) = filtered_vpackage(q, 0, additional, max_depth_par, split_keep_group, vdir, 0, 0);
     }
     if (m == exactly) {
-        return filtered_vpackage(p, h, exactly, dimen_par(split_max_depth_code), split_off_group, vdir, 0, 0);
+        return filtered_vpackage(p, h, exactly, split_max_depth_par, split_off_group, vdir, 0, 0);
     } else {
-        return filtered_vpackage(p, 0, additional, dimen_par(max_depth_code), split_off_group, vdir, 0, 0);
+        return filtered_vpackage(p, 0, additional, max_depth_par, split_off_group, vdir, 0, 0);
     }
 }
 
@@ -2114,13 +2103,13 @@ void begin_box(int box_context)
             set_saved_record(0, saved_boxcontext, 0, box_context);
             switch (abs(cur_list.mode_field)) {
                 case vmode:
-                    spec_direction = body_direction;
+                    spec_direction = body_direction_par;
                     break;
                 case hmode:
-                    spec_direction = text_direction;
+                    spec_direction = text_direction_par;
                     break;
                 case mmode:
-                    spec_direction = math_direction;
+                    spec_direction = math_direction_par;
                     break;
             }
             if (k == hmode) {
@@ -2140,13 +2129,13 @@ void begin_box(int box_context)
             push_nest();
             cur_list.mode_field = -k;
             if (k == vmode) {
-                prev_depth = ignore_depth;
-                if (every_vbox != null)
-                    begin_token_list(every_vbox, every_vbox_text);
+                prev_depth_par = ignore_depth;
+                if (every_vbox_par != null)
+                    begin_token_list(every_vbox_par, every_vbox_text);
             } else {
-                space_factor = 1000;
-                if (every_hbox != null)
-                    begin_token_list(every_hbox, every_hbox_text);
+                space_factor_par = 1000;
+                if (every_hbox_par != null)
+                    begin_token_list(every_hbox_par, every_hbox_text);
             }
             return;
             break;
diff --git a/source/texk/web2c/luatexdir/tex/primitive.w b/source/texk/web2c/luatexdir/tex/primitive.w
index a173e133d44f3035833c567d6f207088e7db7f98..8c6592c9edfff75e965dcc4cf71bffb4bcd17179 100644
--- a/source/texk/web2c/luatexdir/tex/primitive.w
+++ b/source/texk/web2c/luatexdir/tex/primitive.w
@@ -555,7 +555,7 @@ void print_cmd_chr(quarterword cmd, halfword chr_code)
         print_hex(chr_code);
         break;
     case math_given_cmd:
-        if (mathoption_int_par(c_mathoption_umathcode_meaning_code) == 1) {
+        if (math_umathcode_meaning_par == 1) {
             tprint_esc("Umathchar");
             show_mathcode_value(mathchar_from_integer(chr_code, tex_mathcode));
         } else {
diff --git a/source/texk/web2c/luatexdir/tex/printing.w b/source/texk/web2c/luatexdir/tex/printing.w
index 478d55f88ba26cb7a222bb55581e2e615b496b6f..006392810b92d52ddc6d2a35f4ef8b7cb7eac9aa 100644
--- a/source/texk/web2c/luatexdir/tex/printing.w
+++ b/source/texk/web2c/luatexdir/tex/printing.w
@@ -22,8 +22,6 @@
 #include "lua/luatex-api.h" /* for luatex_banner */
 
 @ @c
-#define font_id_text(A) cs_text(font_id_base+(A))
-
 #define wlog(A)  fputc(A,log_file)
 #define wterm(A) fputc(A,term_out)
 
@@ -182,7 +180,7 @@ void print_char(int s)
         formatted_warning("print","weird character %i",s);
         return;
     }
-    if (s == int_par(new_line_char_code)) {
+    if (s == new_line_char_par) {
         if (selector < pseudo) {
             print_ln();
             return;
@@ -270,7 +268,7 @@ void print(int s)
                 print_char(s);
                 return;
             }
-            if (s == int_par(new_line_char_code)) {
+            if (s == new_line_char_par) {
                 if (selector < pseudo) {
                     print_ln();
                     return;
@@ -364,7 +362,7 @@ void tprint(const char *sss)
 {
     char *buffer = NULL;
     int i = 0; /* buffer index */
-    int newlinechar = int_par(new_line_char_code);
+    int newlinechar = new_line_char_par;
     int dolog = 0;
     int doterm = 0;
     switch (selector) {
@@ -509,22 +507,22 @@ void log_banner(const char *v)
         "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
         "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
     };
-    unsigned month = (unsigned) int_par(month_code);
+    unsigned month = (unsigned) month_par;
     if (month > 12)
         month = 0;
     fprintf(log_file, "This is " MyName ", Version %s%s ", v, WEB2CVERSION);
     print(format_ident);
     print_char(' ');
     print_char(' ');
-    print_int(int_par(day_code));
+    print_int(day_par);
     print_char(' ');
     fprintf(log_file, "%s", months[month]);
     print_char(' ');
-    print_int(int_par(year_code));
+    print_int(year_par);
     print_char(' ');
-    print_two(int_par(time_code) / 60);
+    print_two(time_par / 60);
     print_char(':');
-    print_two(int_par(time_code) % 60);
+    print_two(time_par % 60);
     if (shellenabledp) {
         wlog_cr();
         wlog(' ');
@@ -550,7 +548,7 @@ the user's escape character (which is usually a backslash).
 @c
 void print_esc(str_number s)
 {
-    int c = int_par(escape_char_code); /* Set variable |c| to the current escape character */
+    int c = escape_char_par; /* Set variable |c| to the current escape character */
     if (c >= 0 && c < STRING_OFFSET)
         print(c);
     print(s);
@@ -561,7 +559,7 @@ void print_esc(str_number s)
 @c
 void tprint_esc(const char *s)
 {
-    int c = int_par(escape_char_code); /* Set variable |c| to the current escape character */
+    int c = escape_char_par; /* Set variable |c| to the current escape character */
     if (c >= 0 && c < STRING_OFFSET)
         print(c);
     tprint(s);
@@ -724,8 +722,7 @@ void print_cs(int p)
         } else {
             print_esc(t);
             if (single_letter(t)) {
-                if (get_cat_code(int_par(cat_code_table_code),
-                                 pool_to_unichar(str_string(t))) == letter_cmd)
+                if (get_cat_code(cat_code_table_par, pool_to_unichar(str_string(t))) == letter_cmd)
                     print_char(' ');
             } else {
                 print_char(' ');
@@ -851,7 +848,7 @@ void print_font_identifier(internal_font_number f)
         tprint_esc("FONT");
         print_int(f);
     }
-    if (int_par(tracing_fonts_code) > 0) {
+    if (tracing_fonts_par > 0) {
         tprint(" (");
         print_font_name(f);
         if (font_size(f) != font_dsize(f)) {
@@ -955,8 +952,8 @@ int breadth_max;     /* maximum number of items shown at the same list level */
 @c
 void show_box(halfword p)
 {
-    depth_threshold = int_par(show_box_depth_code);
-    breadth_max = int_par(show_box_breadth_code);
+    depth_threshold = show_box_depth_par;
+    breadth_max = show_box_breadth_par;
     if (breadth_max <= 0)
         breadth_max = 5;
     /* the show starts at |p| */
@@ -1072,7 +1069,7 @@ Here are two routines that adjust the destination of print commands:
 void begin_diagnostic(void)
 {
     global_old_setting = selector;
-    if ((int_par(tracing_online_code) <= 0) && (selector == term_and_log)) {
+    if ((tracing_online_par <= 0) && (selector == term_and_log)) {
         decr(selector);
         if (history == spotless)
             history = warning_issued;
diff --git a/source/texk/web2c/luatexdir/tex/scanning.h b/source/texk/web2c/luatexdir/tex/scanning.h
index 729fcda20ef4f08bff11f87afda66cf61a28ebc7..f5f620c6746771999ed267f81898c156e589ef82 100644
--- a/source/texk/web2c/luatexdir/tex/scanning.h
+++ b/source/texk/web2c/luatexdir/tex/scanning.h
@@ -45,6 +45,8 @@ extern void scan_something_internal(int level, boolean negative);
 
 extern void scan_limited_int(int max, const char *name);
 
+extern void negate_cur_val(boolean delete_glue);
+
 #  define scan_register_num() scan_limited_int(65535,"register code")
 #  define scan_mark_num() scan_limited_int(65535,"marks code")
 #  define scan_char_num() scan_limited_int(biggest_char,"character code")
diff --git a/source/texk/web2c/luatexdir/tex/scanning.w b/source/texk/web2c/luatexdir/tex/scanning.w
index 6e454417aeee1a454c6cc39b425a7a568f0d0b5c..658f149adafac212c6ff870dc9d2c92d866cc53b 100644
--- a/source/texk/web2c/luatexdir/tex/scanning.w
+++ b/source/texk/web2c/luatexdir/tex/scanning.w
@@ -22,19 +22,6 @@
 #include "ptexlib.h"
 
 @ @c
-#define prev_depth cur_list.prev_depth_field
-#define space_factor cur_list.space_factor_field
-#define par_shape_ptr  equiv(par_shape_loc)
-#define font_id_text(A) cs_text(font_id_base+(A))
-
-#define attribute(A) eqtb[attribute_base+(A)].hh.rh
-#define dimen(A) eqtb[scaled_base+(A)].hh.rh
-#undef skip
-#define skip(A) eqtb[skip_base+(A)].hh.rh
-#define mu_skip(A) eqtb[mu_skip_base+(A)].hh.rh
-#define count(A) eqtb[count_base+(A)].hh.rh
-#define box(A) equiv(box_base+(A))
-
 static void scan_expr(void);
 
 @ Let's turn now to some procedures that \TeX\ calls upon frequently to digest
@@ -165,7 +152,7 @@ static void downgrade_cur_val(boolean delete_glue)
     decr(cur_val_level);
 }
 
-static void negate_cur_val(boolean delete_glue)
+void negate_cur_val(boolean delete_glue)
 {
     halfword m;
     if (cur_val_level >= glue_val_level) {
@@ -208,6 +195,9 @@ static boolean short_scan_something_internal(int cmd, int chr, int level,
         scanned_result(eqtb[m].cint, int_val_level);
         break;
     case assign_dir_cmd:
+        if (m == (int_base + line_direction_code)) {
+            m = int_base + text_direction_code;
+        }
         scanned_result(eqtb[m].cint, dir_val_level);
         break;
     case assign_dimen_cmd:
@@ -215,11 +205,9 @@ static boolean short_scan_something_internal(int cmd, int chr, int level,
         break;
     case assign_glue_cmd:
         scanned_result(equiv(m), glue_val_level);
-// cur_val = new_spec(cur_val);
         break;
     case assign_mu_glue_cmd:
         scanned_result(equiv(m), mu_val_level);
-// cur_val = new_spec(cur_val);
         break;
     case math_style_cmd:
         scanned_result(m, int_val_level);
@@ -239,9 +227,9 @@ static boolean short_scan_something_internal(int cmd, int chr, int level,
             else
                 scanned_result(0, int_val_level);
         } else if (m == vmode) {
-            scanned_result(prev_depth, dimen_val_level);
+            scanned_result(prev_depth_par, dimen_val_level);
         } else {
-            scanned_result(space_factor, int_val_level);
+            scanned_result(space_factor_par, int_val_level);
         }
         break;
     case set_prev_graf_cmd:
@@ -279,10 +267,10 @@ static boolean short_scan_something_internal(int cmd, int chr, int level,
         break;
     case set_tex_shape_cmd:
         /* Fetch the |par_shape| size */
-        if (par_shape_ptr == null)
+        if (par_shape_par_ptr == null)
             cur_val = 0;
         else
-            cur_val = vinfo(par_shape_ptr + 1);
+            cur_val = vinfo(par_shape_par_ptr + 1);
         cur_val_level = int_val_level;
         break;
     case set_etex_shape_cmd:
@@ -381,17 +369,17 @@ static boolean short_scan_something_internal(int cmd, int chr, int level,
                 case par_shape_dimen_code:
                     q = cur_chr - par_shape_length_code;
                     scan_int();
-                    if ((par_shape_ptr == null) || (cur_val <= 0)) {
+                    if ((par_shape_par_ptr == null) || (cur_val <= 0)) {
                         cur_val = 0;
                     } else {
                         if (q == 2) {
                             q = cur_val % 2;
                             cur_val = (cur_val + q) / 2;
                         }
-                        if (cur_val > vinfo(par_shape_ptr + 1))
-                            cur_val = vinfo(par_shape_ptr + 1);
+                        if (cur_val > vinfo(par_shape_par_ptr + 1))
+                            cur_val = vinfo(par_shape_par_ptr + 1);
                         cur_val =
-                            varmem[par_shape_ptr + 2 * cur_val - q + 1].cint;
+                            varmem[par_shape_par_ptr + 2 * cur_val - q + 1].cint;
                     }
                     cur_val_level = dimen_val_level;
                     break;
@@ -614,7 +602,7 @@ void scan_something_internal(int level, boolean negative)
                 cur_val1 = get_sf_code(cur_val);
                 scanned_result(cur_val1, int_val_level);
             } else if (m == cat_code_base) {
-                cur_val1 = get_cat_code(int_par(cat_code_table_code), cur_val);
+                cur_val1 = get_cat_code(cat_code_table_par, cur_val);
                 scanned_result(cur_val1, int_val_level);
             } else {
                 confusion("def_char");
@@ -690,11 +678,11 @@ void scan_something_internal(int level, boolean negative)
             } else {
                 cur_val1 = get_math_param(cur_val1, cur_chr);
                 if (cur_val1 == thin_mu_skip_code)
-                    cur_val1 = glue_par(thin_mu_skip_code);
+                    cur_val1 = thin_mu_skip_par;
                 else if (cur_val1 == med_mu_skip_code)
-                    cur_val1 = glue_par(med_mu_skip_code);
+                    cur_val1 = med_mu_skip_par;
                 else if (cur_val1 == thick_mu_skip_code)
-                    cur_val1 = glue_par(thick_mu_skip_code);
+                    cur_val1 = thick_mu_skip_par;
                 scanned_result(cur_val1, mu_val_level);
             }
             break;
@@ -803,28 +791,28 @@ void scan_something_internal(int level, boolean negative)
                     goto DEFAULT;
                     break;
                 case 2:
-                    cur_val = get_pre_hyphen_char(int_par(language_code));
+                    cur_val = get_pre_hyphen_char(language_par);
                     cur_val_level = int_val_level;
                     break;
                 case 3:
-                    cur_val = get_post_hyphen_char(int_par(language_code));
+                    cur_val = get_post_hyphen_char(language_par);
                     cur_val_level = int_val_level;
                     break;
                 case 4:
-                    cur_val = get_pre_exhyphen_char(int_par(language_code));
+                    cur_val = get_pre_exhyphen_char(language_par);
                     cur_val_level = int_val_level;
                     break;
                 case 5:
-                    cur_val = get_post_exhyphen_char(int_par(language_code));
+                    cur_val = get_post_exhyphen_char(language_par);
                     cur_val_level = int_val_level;
                     break;
                 case 6:
-                    cur_val = get_hyphenation_min(int_par(language_code));
+                    cur_val = get_hyphenation_min(language_par);
                     cur_val_level = int_val_level;
                     break;
                 case 7:
                     scan_int();
-                    cur_val = get_hj_code(int_par(language_code),cur_val);
+                    cur_val = get_hj_code(language_par,cur_val);
                     cur_val_level = int_val_level;
                     break;
             }
@@ -1371,7 +1359,7 @@ void scan_dimen(boolean mu, boolean inf, boolean shortcut)
     } else if (scan_keyword("ex")) {
         v = x_height(get_cur_font());
     } else if (scan_keyword("px")) {
-        v = dimen_par(px_dimen_code);
+        v = px_dimen_par;
     } else {
         goto PICKUP_UNIT;
     }
@@ -1428,13 +1416,13 @@ void scan_dimen(boolean mu, boolean inf, boolean shortcut)
     goto BAD_NEWS;
   SCALE_VALUE:
     /* Adjust (f) for the magnification ratio */
-    if (!is_true) {
+    if (is_true) {
         /* maybe at some point we will drop mag completely, even in dvi mode */
         if (output_mode_used <= OMODE_DVI) {
             prepare_mag();
-            if (int_par(mag_code) != 1000) {
-                cur_val = xn_over_d(cur_val, 1000, int_par(mag_code));
-                f = (1000 * f + 0200000 * tex_remainder) / int_par(mag_code);
+            if (mag_par != 1000) {
+                cur_val = xn_over_d(cur_val, 1000, mag_par);
+                f = (1000 * f + 0200000 * tex_remainder) / mag_par;
                 cur_val = cur_val + (f / 0200000);
                 f = f % 0200000;
             }
@@ -1847,11 +1835,11 @@ halfword scan_rule_spec(void)
     }
     if (cur_cmd == vrule_cmd) {
         width(q) = default_rule;
-        rule_dir(q) = body_direction;
+        rule_dir(q) = body_direction_par;
     } else {
         height(q) = default_rule;
         depth(q) = 0;
-        rule_dir(q) = text_direction;
+        rule_dir(q) = text_direction_par;
     }
   RESWITCH:
     if (scan_keyword("width")) {
@@ -2167,15 +2155,14 @@ parenthesis.
 
 @c
 typedef enum {
-    expr_none = 0,              /* \.( seen, or \.( $\langle\it expr\rangle$ \.) seen */
-    expr_add = 1,               /* \.( $\langle\it expr\rangle$ \.+ seen */
-    expr_sub = 2,               /* \.( $\langle\it expr\rangle$ \.- seen */
-    expr_mult = 3,              /* $\langle\it term\rangle$ \.* seen */
-    expr_div = 4,               /* $\langle\it term\rangle$ \./ seen */
-    expr_scale = 5,             /* $\langle\it term\rangle$ \.*  $\langle\it factor\rangle$ \./ seen */
+    expr_none  = 0, /* \.( seen, or \.( $\langle\it expr\rangle$ \.) seen */
+    expr_add   = 1, /* \.( $\langle\it expr\rangle$ \.+ seen */
+    expr_sub   = 2, /* \.( $\langle\it expr\rangle$ \.- seen */
+    expr_mult  = 3, /* $\langle\it term\rangle$ \.* seen */
+    expr_div   = 4, /* $\langle\it term\rangle$ \./ seen */
+    expr_scale = 5, /* $\langle\it term\rangle$ \.*  $\langle\it factor\rangle$ \./ seen */
 } expression_states;
 
-
 @  We want to make sure that each term and (intermediate) result is in
   the proper range.  Integer values must not exceed |infinity|
   ($2^{31}-1$) in absolute value, dimensions must not exceed |max_dimen|
@@ -2212,12 +2199,6 @@ term so far and |s| is the state of its evaluation; finally |n| is the
 numerator for a combined multiplication and division, if any.
 
 @c
-#define expr_type(A) type((A)+1)
-#define expr_state(A) subtype((A)+1)
-#define expr_e_field(A) vlink((A)+1)    /* saved expression so far */
-#define expr_t_field(A) vlink((A)+2)    /* saved term so far */
-#define expr_n_field(A) vinfo((A)+2)    /* saved numerator */
-
 #define expr_add_sub(A,B,C) add_or_sub((A),(B),(C),(r==expr_sub))
 #define expr_a(A,B) expr_add_sub((A),(B),max_dimen)
 
diff --git a/source/texk/web2c/luatexdir/tex/texfileio.w b/source/texk/web2c/luatexdir/tex/texfileio.w
index e04bf991afb0909f3a9b35209465a741b58163b6..8b21cd02e71109ccc932b0dad3afbf21acfe8ddd 100644
--- a/source/texk/web2c/luatexdir/tex/texfileio.w
+++ b/source/texk/web2c/luatexdir/tex/texfileio.w
@@ -25,10 +25,6 @@
 #include <string.h>
 #include <kpathsea/absolute.h>
 
-@ @c
-#define end_line_char int_par(end_line_char_code)
-
-
 @ The bane of portability is the fact that different operating systems treat
 input and output quite differently, perhaps because computer scientists
 have not given sufficient attention to this problem. People have felt somehow
@@ -116,7 +112,7 @@ char *luatex_find_read_file(const char *s, int n, int callback_index)
     char *ftemp = NULL;
     int callback_id = callback_defined(callback_index);
     if (callback_id > 0) {
-        (void) run_callback(callback_id, "dS->S", n, s, &ftemp);
+        (void) run_callback(callback_id, "dS->R", n, s, &ftemp);
     } else {
         /* use kpathsea here */
         ftemp = find_in_output_directory(s);
@@ -844,7 +840,7 @@ void open_log_file(void)
         input_stack[input_ptr] = cur_input;     /* make sure bottom level is in memory */
         tprint_nl("**");
         l = input_stack[0].limit_field; /* last position of first line */
-        if (buffer[l] == end_line_char)
+        if (buffer[l] == end_line_char_par)
             decr(l);            /* TODO: multichar endlinechar */
         for (k = 1; k <= l; k++)
             print_char(buffer[k]);
@@ -978,7 +974,7 @@ void start_input(void)
     if (end_line_char_inactive)
         decr(ilimit);
     else
-        buffer[ilimit] = (packed_ASCII_code) end_line_char;
+        buffer[ilimit] = (packed_ASCII_code) end_line_char_par;
     first = ilimit + 1;
     iloc = istart;
 }
@@ -1137,7 +1133,7 @@ boolean zopen_w_input(FILE ** f, const char *fname, int format,
     char *fnam;
     callbackid = callback_defined(find_format_file_callback);
     if (callbackid > 0) {
-        res = run_callback(callbackid, "S->S", fname, &fnam);
+        res = run_callback(callbackid, "S->R", fname, &fnam);
         if (res && fnam && strlen(fnam) > 0) {
             *f = fopen(fnam, fopen_mode);
             if (*f == NULL) {
diff --git a/source/texk/web2c/luatexdir/tex/texmath.h b/source/texk/web2c/luatexdir/tex/texmath.h
index f36644e997d0f5de407473ecd12a1ecaaa35c914..93e85b462217f7269dbdecfc08b074ac606d0130 100644
--- a/source/texk/web2c/luatexdir/tex/texmath.h
+++ b/source/texk/web2c/luatexdir/tex/texmath.h
@@ -109,8 +109,6 @@ void print_math_style(void);
 #  define script_size 1
 #  define script_script_size 2
 
-#  define math_direction int_par(math_direction_code)
-
 #  define dir_math_save cur_list.math_field
 #  define m_style cur_list.math_style_field
 #  define init_math_fields() do {               \
diff --git a/source/texk/web2c/luatexdir/tex/texmath.w b/source/texk/web2c/luatexdir/tex/texmath.w
index 8bfe570729dbf5a61425e6c6b4a11c3040994f0a..4d588079ce75481bbd3966bcfc8eefca372dd530 100644
--- a/source/texk/web2c/luatexdir/tex/texmath.w
+++ b/source/texk/web2c/luatexdir/tex/texmath.w
@@ -21,16 +21,10 @@
 #include "ptexlib.h"
 
 @ @c
-#define mode          cur_list.mode_field
-#define head          cur_list.head_field
-#define tail          cur_list.tail_field
-#define prev_graf     cur_list.pg_field
-#define eTeX_aux      cur_list.eTeX_aux_field
-#define delim_ptr     eTeX_aux
-#define space_factor  cur_list.space_factor_field
-#define incompleat_noad cur_list.incompleat_noad_field
-
-#define cur_fam int_par(cur_fam_code)
+#define mode     mode_par
+#define tail     tail_par
+#define head     head_par
+#define dir_save dirs_par
 
 /*
 
@@ -59,13 +53,6 @@ int scan_math(pointer, int);
 int scan_math_style(pointer, int);
 pointer fin_mlist(pointer);
 
-#define hsize            dimen_par(hsize_code)
-#define hang_indent      dimen_par(hang_indent_code)
-#define hang_after       int_par(hang_after_code)
-#define every_math       equiv(every_math_loc)
-#define every_display    equiv(every_display_loc)
-#define par_shape_ptr    equiv(par_shape_loc)
-
 @ When \TeX\ reads a formula that is enclosed between \.\$'s, it constructs an
 {\sl mlist}, which is essentially a tree structure representing that
 formula.  An mlist is a linear sequence of items, but we can regard it as
@@ -161,10 +148,10 @@ subroutine empties the current list, assuming that |abs(mode)=mmode|.
 void flush_math(void)
 {
     flush_node_list(vlink(head));
-    flush_node_list(incompleat_noad);
+    flush_node_list(incompleat_noad_par);
     vlink(head) = null;
     tail = head;
-    incompleat_noad = null;
+    incompleat_noad_par = null;
 }
 
 @ Before we can do anything in math mode, we need fonts.
@@ -189,7 +176,7 @@ void def_fam_fnt(int fam_id, int size_id, int f, int lvl)
     sa_value.int_value = f;
     set_sa_item(math_fam_head, n, sa_value, lvl);
     fixup_math_parameters(fam_id, size_id, f, lvl);
-    if (int_par(tracing_assigns_code) > 1) {
+    if (tracing_assigns_par > 1) {
         begin_diagnostic();
         tprint("{assigning");
         print_char(' ');
@@ -215,7 +202,7 @@ static void unsave_math_fam_data(int gl)
         if (st.level > 0) {
             rawset_sa_item(math_fam_head, st.code, st.value);
             /* now do a trace message, if requested */
-            if (int_par(tracing_restores_code) > 1) {
+            if (tracing_restores_par > 1) {
                 int size_id = st.code / 256;
                 int fam_id = st.code % 256;
                 begin_diagnostic();
@@ -248,7 +235,7 @@ void def_math_param(int param_id, int style_id, scaled value, int lvl)
     sa_tree_item sa_value = { 0 };
     sa_value.int_value = (int) value;
     set_sa_item(math_param_head, n, sa_value, lvl);
-    if (int_par(tracing_assigns_code) > 1) {
+    if (tracing_assigns_par > 1) {
         begin_diagnostic();
         tprint("{assigning");
         print_char(' ');
@@ -280,7 +267,7 @@ static void unsave_math_param_data(int gl)
         if (st.level > 0) {
             rawset_sa_item(math_param_head, st.code, st.value);
             /* now do a trace message, if requested */
-            if (int_par(tracing_restores_code) > 1) {
+            if (tracing_restores_par > 1) {
                 int param_id = st.code % 256;
                 int style_id = st.code / 256;
                 begin_diagnostic();
@@ -875,22 +862,22 @@ is about to be processed. The parameter is a code like |math_group|.
 static void new_save_level_math(group_code c)
 {
     set_saved_record(0, saved_textdir, 0, text_dir_ptr);
-    text_dir_ptr = new_dir(math_direction);
+    text_dir_ptr = new_dir(math_direction_par);
     incr(save_ptr);
     new_save_level(c);
-    eq_word_define(int_base + body_direction_code, math_direction);
-    eq_word_define(int_base + par_direction_code, math_direction);
-    eq_word_define(int_base + text_direction_code, math_direction);
+    eq_word_define(int_base + body_direction_code, math_direction_par);
+    eq_word_define(int_base + par_direction_code, math_direction_par);
+    eq_word_define(int_base + text_direction_code, math_direction_par);
 }
 
 @ @c
 static void push_math(group_code c, int mstyle)
 {
-    if (math_direction != text_direction)
+    if (math_direction_par != text_direction_par)
         dir_math_save = true;
     push_nest();
     mode = -mmode;
-    incompleat_noad = null;
+    incompleat_noad_par = null;
     m_style = mstyle;
     new_save_level_math(c);
 }
@@ -900,8 +887,8 @@ static void enter_ordinary_math(void)
 {
     push_math(math_shift_group, text_style);
     eq_word_define(int_base + cur_fam_code, -1);
-    if (every_math != null)
-        begin_token_list(every_math, every_math_text);
+    if (every_math_par != null)
+        begin_token_list(every_math_par, every_math_text);
 }
 
 @ @c
@@ -993,7 +980,7 @@ static boolean math_and_text_reversed_p(void)
     while (i < save_ptr) {
         if (save_type(i) == restore_old_value &&
             save_value(i) == int_base + par_direction_code) {
-            if (textdir_opposite(math_direction, save_value(i - 1)))
+            if (textdir_opposite(math_direction_par, save_value(i - 1)))
                 return true;
         }
         i++;
@@ -1032,27 +1019,27 @@ void enter_display_math(void)
     /* now we are in vertical mode, working on the list that will contain the display */
     /* A displayed equation is considered to be three lines long, so we
        calculate the length and offset of line number |prev_graf+2|. */
-    if (par_shape_ptr == null) {
-        if ((hang_indent != 0) &&
-            (((hang_after >= 0) && (prev_graf + 2 > hang_after)) ||
-             (prev_graf + 1 < -hang_after))) {
-            l = hsize - abs(hang_indent);
-            if (hang_indent > 0)
-                s = hang_indent;
+    if (par_shape_par_ptr == null) {
+        if ((hang_indent_par != 0) && (((hang_after_par >= 0) && (prev_graf_par + 2 > hang_after_par)) || (prev_graf_par + 1 < -hang_after_par))) {
+            halfword used_hang_indent = swap_hang_indent(hang_indent_par);
+            l = hsize_par - abs(used_hang_indent);
+            if (used_hang_indent > 0)
+                s = used_hang_indent;
             else
                 s = 0;
         } else {
-            l = hsize;
+            l = hsize_par;
             s = 0;
         }
     } else {
-        n = vinfo(par_shape_ptr + 1);
-        if (prev_graf + 2 >= n)
-            p = par_shape_ptr + 2 * n + 1;
+        n = vinfo(par_shape_par_ptr + 1);
+        if (prev_graf_par + 2 >= n)
+            p = par_shape_par_ptr + 2 * n + 1;
         else
-            p = par_shape_ptr + 2 * (prev_graf + 2) + 1;
+            p = par_shape_par_ptr + 2 * (prev_graf_par + 2) + 1;
         s = varmem[(p - 1)].cint;
         l = varmem[p].cint;
+        s = swap_parshape_indent(s,l);
     }
 
     push_math(math_shift_group, display_style);
@@ -1062,8 +1049,8 @@ void enter_display_math(void)
     eq_word_define(dimen_base + display_width_code, l);
     eq_word_define(dimen_base + display_indent_code, s);
     eq_word_define(int_base + pre_display_direction_code, (math_and_text_reversed_p() ? -1 : 0));
-    if (every_display != null)
-        begin_token_list(every_display, every_display_text);
+    if (every_display_par != null)
+        begin_token_list(every_display_par, every_display_text);
     if (nest_ptr == 1) {
         checked_page_filter(before_display);
         build_page();
@@ -1076,8 +1063,6 @@ void enter_display_math(void)
  (the class is passed on for conversion to \.{\\mathchar}).
 
 @c
-#define fam_in_range ((cur_fam>=0)&&(cur_fam<256))
-
 static delcodeval do_scan_extdef_del_code(int extcode, boolean doclass)
 {
     const char *hlp[] = {
@@ -1354,8 +1339,8 @@ int scan_math(pointer p, int mstyle)
     }
     type(p) = math_char_node;
     math_character(p) = mval.character_value;
-    if ((mval.class_value == math_use_current_family_code) && fam_in_range)
-        math_fam(p) = cur_fam;
+    if ((mval.class_value == math_use_current_family_code) && cur_fam_par_in_range)
+        math_fam(p) = cur_fam_par;
     else
         math_fam(p) = mval.family_value;
     return 0;
@@ -1385,8 +1370,8 @@ void set_math_char(mathcodeval mval)
         math_character(nucleus(p)) = mval.character_value;
         math_fam(nucleus(p)) = mval.family_value;
         if (mval.class_value == math_use_current_family_code) {
-            if (fam_in_range)
-                math_fam(nucleus(p)) = cur_fam;
+            if (cur_fam_par_in_range)
+                math_fam(nucleus(p)) = cur_fam_par;
             subtype(p) = ord_noad_type;
         } else {
             switch (mval.class_value) {
@@ -1654,8 +1639,8 @@ void math_ac(void)
         q = new_node(math_char_node, 0);
         top_accent_chr(tail) = q;
         math_character(top_accent_chr(tail)) = t.character_value;
-        if ((t.class_value == math_use_current_family_code) && fam_in_range)
-            math_fam(top_accent_chr(tail)) = cur_fam;
+        if ((t.class_value == math_use_current_family_code) && cur_fam_par_in_range)
+            math_fam(top_accent_chr(tail)) = cur_fam_par;
         else
             math_fam(top_accent_chr(tail)) = t.family_value;
     }
@@ -1663,8 +1648,8 @@ void math_ac(void)
         q = new_node(math_char_node, 0);
         bot_accent_chr(tail) = q;
         math_character(bot_accent_chr(tail)) = b.character_value;
-        if ((b.class_value == math_use_current_family_code) && fam_in_range)
-            math_fam(bot_accent_chr(tail)) = cur_fam;
+        if ((b.class_value == math_use_current_family_code) && cur_fam_par_in_range)
+            math_fam(bot_accent_chr(tail)) = cur_fam_par;
         else
             math_fam(bot_accent_chr(tail)) = b.family_value;
     }
@@ -1672,8 +1657,8 @@ void math_ac(void)
         q = new_node(math_char_node, 0);
         overlay_accent_chr(tail) = q;
         math_character(overlay_accent_chr(tail)) = o.character_value;
-        if ((o.class_value == math_use_current_family_code) && fam_in_range)
-            math_fam(overlay_accent_chr(tail)) = cur_fam;
+        if ((o.class_value == math_use_current_family_code) && cur_fam_par_in_range)
+            math_fam(overlay_accent_chr(tail)) = cur_fam_par;
         else
             math_fam(overlay_accent_chr(tail)) = o.family_value;
     }
@@ -1793,7 +1778,7 @@ void math_fraction(void)
     pointer q;
     halfword options = 0;
     c = cur_chr;
-    if (incompleat_noad != null) {
+    if (incompleat_noad_par != null) {
         const char *hlp[] = {
             "I'm ignoring this fraction specification, since I don't",
             "know whether a construction like `x \\over y \\over z'",
@@ -1808,25 +1793,25 @@ void math_fraction(void)
             scan_normal_dimen();
         tex_error("Ambiguous; you need another { and }", hlp);
     } else {
-        incompleat_noad = new_node(fraction_noad, 0);
-        numerator(incompleat_noad) = new_node(sub_mlist_node, 0);
-        math_list(numerator(incompleat_noad)) = vlink(head);
+        incompleat_noad_par = new_node(fraction_noad, 0);
+        numerator(incompleat_noad_par) = new_node(sub_mlist_node, 0);
+        math_list(numerator(incompleat_noad_par)) = vlink(head);
         vlink(head) = null;
         tail = head;
         m_style = cramped_style(m_style);
 
         if ((c % delimited_code) == skewed_code) {
             q = new_node(delim_node, 0);
-            middle_delimiter(incompleat_noad) = q;
-            scan_delimiter(middle_delimiter(incompleat_noad), no_mathcode);
+            middle_delimiter(incompleat_noad_par) = q;
+            scan_delimiter(middle_delimiter(incompleat_noad_par), no_mathcode);
         }
         if (c >= delimited_code) {
             q = new_node(delim_node, 0);
-            left_delimiter(incompleat_noad) = q;
+            left_delimiter(incompleat_noad_par) = q;
             q = new_node(delim_node, 0);
-            right_delimiter(incompleat_noad) = q;
-            scan_delimiter(left_delimiter(incompleat_noad), no_mathcode);
-            scan_delimiter(right_delimiter(incompleat_noad), no_mathcode);
+            right_delimiter(incompleat_noad_par) = q;
+            scan_delimiter(left_delimiter(incompleat_noad_par), no_mathcode);
+            scan_delimiter(right_delimiter(incompleat_noad_par), no_mathcode);
         }
         switch (c % delimited_code) {
             case above_code:
@@ -1837,15 +1822,15 @@ void math_fraction(void)
                         break;
                     }
                 }
-                fractionoptions(incompleat_noad) = options;
+                fractionoptions(incompleat_noad_par) = options;
                 scan_normal_dimen();
-                thickness(incompleat_noad) = cur_val;
+                thickness(incompleat_noad_par) = cur_val;
                 break;
             case over_code:
-                thickness(incompleat_noad) = default_code;
+                thickness(incompleat_noad_par) = default_code;
                 break;
             case atop_code:
-                thickness(incompleat_noad) = 0;
+                thickness(incompleat_noad_par) = 0;
                 break;
             case skewed_code:
                 while (1) {
@@ -1857,8 +1842,8 @@ void math_fraction(void)
                         break;
                     }
                 }
-                fractionoptions(incompleat_noad) = options;
-                thickness(incompleat_noad) = 0;
+                fractionoptions(incompleat_noad_par) = options;
+                thickness(incompleat_noad_par) = 0;
                 break;
         }
     }
@@ -1874,24 +1859,24 @@ current mlist; this |fence_noad| has not yet been appended.
 pointer fin_mlist(pointer p)
 {
     pointer q;                  /* the mlist to return */
-    if (incompleat_noad != null) {
-        if (denominator(incompleat_noad) != null) {
-            type(denominator(incompleat_noad)) = sub_mlist_node;
+    if (incompleat_noad_par != null) {
+        if (denominator(incompleat_noad_par) != null) {
+            type(denominator(incompleat_noad_par)) = sub_mlist_node;
         } else {
             q = new_node(sub_mlist_node, 0);
-            denominator(incompleat_noad) = q;
+            denominator(incompleat_noad_par) = q;
         }
-        math_list(denominator(incompleat_noad)) = vlink(head);
+        math_list(denominator(incompleat_noad_par)) = vlink(head);
         if (p == null) {
-            q = incompleat_noad;
+            q = incompleat_noad_par;
         } else {
-            q = math_list(numerator(incompleat_noad));
+            q = math_list(numerator(incompleat_noad_par));
             if ((type(q) != fence_noad) || (subtype(q) != left_noad_side)
-                || (delim_ptr == null))
+                || (delim_par == null))
                 confusion("right");     /* this can't happen */
-            math_list(numerator(incompleat_noad)) = vlink(delim_ptr);
-            vlink(delim_ptr) = incompleat_noad;
-            vlink(incompleat_noad) = p;
+            math_list(numerator(incompleat_noad_par)) = vlink(delim_par);
+            vlink(delim_par) = incompleat_noad_par;
+            vlink(incompleat_noad_par) = p;
         }
     } else {
         vlink(tail) = p;
@@ -2063,7 +2048,7 @@ void math_left_right(void)
             push_math(math_left_group, m_style);
             vlink(head) = q;
             tail = p;
-            delim_ptr = p;
+            delim_par = p;
         } else {
             tail_append(new_noad());
             subtype(tail) = inner_noad_type;
@@ -2119,10 +2104,10 @@ static void resume_after_display(void)
     if (cur_group != math_shift_group)
         confusion("display");
     unsave_math();
-    prev_graf = prev_graf + 3;
+    prev_graf_par = prev_graf_par + 3;
     push_nest();
     mode = hmode;
-    space_factor = 1000;
+    space_factor_par = 1000;
     /* this needs to be intercepted in the display math start ! */
     tail_append(make_local_par_node(penalty_par_code));
     get_x_token();
@@ -2145,7 +2130,7 @@ At this time we are in vertical mode (or internal vertical mode).
 
 @c
 #define inject_display_skip_before(g) \
-    switch (display_skip_mode) { \
+    switch (display_skip_mode_par) { \
         case 0 : /* normal tex */ \
             tail_append(new_param_glue(g)); \
             break;\
@@ -2161,7 +2146,7 @@ At this time we are in vertical mode (or internal vertical mode).
     }
 
 #define inject_display_skip_after(g) \
-    switch (display_skip_mode) { \
+    switch (display_skip_mode_par) { \
         case 0 : /* normal tex */ \
             if (g != 0 && glue_is_positive(glue_par(g))) \
                 tail_append(new_param_glue(g)); \
@@ -2192,7 +2177,7 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
     pointer pre_t;              /* tail of pre-adjustment list */
     boolean swap_dir;           /* true if the math and surrounding text dirs are opposed */
     scaled eqno_width;
-    swap_dir = (int_par(pre_display_direction_code) < 0 ? true : false );
+    swap_dir = (pre_display_direction_par < 0 ? true : false );
     if (eqno_box != null && swap_dir)
         l = !l;
     adjust_tail = adjust_head;
@@ -2206,8 +2191,8 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
     pre_t = pre_adjust_tail;
     pre_adjust_tail = null;
     eq_w = width(eq_box);
-    line_w = display_width;
-    line_s = display_indent;
+    line_w = display_width_par;
+    line_s = display_indent_par;
     if (eqno_box == null) {
         eqno_w = 0;
         eqno_width = 0;
@@ -2215,7 +2200,7 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
     } else {
         eqno_w = width(eqno_box);
         eqno_width = eqno_w;
-        eqno_w2 = eqno_w + round_xn_over_d(math_eqno_gap_step, get_math_quad_style(text_style), 1000);
+        eqno_w2 = eqno_w + round_xn_over_d(math_eqno_gap_step_par, get_math_quad_style(text_style), 1000);
         subtype(eqno_box) = equation_number_list; /* new */
      /* build_attribute_list(eqno_box); */ /* probably already set */
    }
@@ -2261,8 +2246,8 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
                     d = 0;
     }
 
-    tail_append(new_penalty(int_par(pre_display_penalty_code)));
-    if ((d + line_s <= pre_display_size) || l) {        /* not enough clearance */
+    tail_append(new_penalty(pre_display_penalty_par));
+    if ((d + line_s <= pre_display_size_par) || l) {        /* not enough clearance */
         g1 = above_display_skip_code;
         g2 = below_display_skip_code;
     } else {
@@ -2280,7 +2265,7 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
      /* it follows that |type(a)=hlist_node| */
 
     if (eqno_box && l && (eqno_w == 0)) {
-     /* if (math_direction==dir_TLT) { */
+     /* if (math_direction_par==dir_TLT) { */
             shift_amount(eqno_box) = 0;
      /* } else {                       */
      /* }                              */
@@ -2294,8 +2279,8 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
         r = new_kern(line_w - eq_w - eqno_w - d);
         if (l) {
             if (swap_dir) {
-                if (math_direction==dir_TLT) {
-                    /* TRT + TLT + \eqno,    (swap_dir=true,  math_direction=TLT, l=true)  */
+                if (math_direction_par==dir_TLT) {
+                    /* TRT + TLT + \eqno,    (swap_dir=true,  math_direction_par=TLT, l=true)  */
 #ifdef DEBUG
         fprintf(stderr, "\nDEBUG: CASE 1\n");
 #endif
@@ -2304,7 +2289,7 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
                     try_couple_nodes(r,eq_box);
                     try_couple_nodes(eq_box,s);
                 } else {
-                    /* TLT + TRT + \eqno,    (swap_dir=true,  math_direction=TRT, l=true) */
+                    /* TLT + TRT + \eqno,    (swap_dir=true,  math_direction_par=TRT, l=true) */
 #ifdef DEBUG
         fprintf(stderr, "\nDEBUG: CASE 2\n");
 #endif
@@ -2312,14 +2297,14 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
                     try_couple_nodes(r,eq_box);
                 }
             } else {
-                if (math_direction==dir_TLT) {
-                    /* TLT + TLT + \leqno,   (swap_dir=false, math_direction=TLT, l=true) */ /* OK */
+                if (math_direction_par==dir_TLT) {
+                    /* TLT + TLT + \leqno,   (swap_dir=false, math_direction_par=TLT, l=true) */ /* OK */
 #ifdef DEBUG
         fprintf(stderr, "\nDEBUG: CASE 3\n");
 #endif
                     s = new_kern(width(r) + eqno_w);
                 } else {
-                    /* TRT + TRT + \leqno,    (swap_dir=false, math_direction=TRT, l=true) */
+                    /* TRT + TRT + \leqno,    (swap_dir=false, math_direction_par=TRT, l=true) */
 #ifdef DEBUG
         fprintf(stderr, "\nDEBUG: CASE 4\n");
 #endif
@@ -2332,13 +2317,13 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
             eq_box = eqno_box;
         } else {
             if (swap_dir) {
-                if (math_direction==dir_TLT) {
-                    /* TRT + TLT + \leqno,   (swap_dir=true,  math_direction=TLT, l=false) */
+                if (math_direction_par==dir_TLT) {
+                    /* TRT + TLT + \leqno,   (swap_dir=true,  math_direction_par=TLT, l=false) */
 #ifdef DEBUG
         fprintf(stderr, "\nDEBUG: CASE 5\n");
 #endif
                 } else {
-                    /* TLT + TRT + \leqno,   (swap_dir=true,  math_direction=TRT, l=false) */
+                    /* TLT + TRT + \leqno,   (swap_dir=true,  math_direction_par=TRT, l=false) */
 #ifdef DEBUG
         fprintf(stderr, "\nDEBUG: CASE 6\n");
 #endif
@@ -2346,14 +2331,14 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
                 try_couple_nodes(eq_box,r);
                 try_couple_nodes(r,eqno_box);
             } else {
-                if (math_direction==dir_TLT) {
-                    /*  TLT + TLT + \eqno,    (swap_dir=false, math_direction=TLT, l=false) */ /* OK */
+                if (math_direction_par==dir_TLT) {
+                    /*  TLT + TLT + \eqno,    (swap_dir=false, math_direction_par=TLT, l=false) */ /* OK */
 #ifdef DEBUG
         fprintf(stderr, "\nDEBUG: CASE 7\n");
 #endif
                     s = new_kern(d);
                 } else {
-                    /* TRT + TRT + \eqno,   (swap_dir=false, math_direction=TRT, l=false) */
+                    /* TRT + TRT + \eqno,   (swap_dir=false, math_direction_par=TRT, l=false) */
 #ifdef DEBUG
         fprintf(stderr, "\nDEBUG: CASE 8\n");
 #endif
@@ -2377,7 +2362,7 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
 
     if ((eqno_box != null) && (eqno_w == 0) && !l) {
         tail_append(new_penalty(inf_penalty));
-     /* if (math_direction==dir_TLT) { */
+     /* if (math_direction_par==dir_TLT) { */
             shift_amount(eqno_box) = line_s + line_w - eqno_width ;
      /* } else {                       */
      /* }                              */
@@ -2396,7 +2381,7 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
         alink(pre_adjust_tail) = alink(tail);
         tail = pre_t;
     }
-    tail_append(new_penalty(int_par(post_display_penalty_code)));
+    tail_append(new_penalty(post_display_penalty_par));
     inject_display_skip_after(g2);
     resume_after_display();
 }
@@ -2442,15 +2427,15 @@ void after_math(void)
         if (cur_cmd == math_shift_cs_cmd) {
             check_inline_math_end();
         }
-        tail_append(new_math(math_surround, before));
+        tail_append(new_math(math_surround_par, before));
         /* begin mathskip code */
-        if (! glue_is_zero(math_skip)) {
-            copy_glue_values(tail,math_skip);
+        if (! glue_is_zero(math_skip_par)) {
+            copy_glue_values(tail,math_skip_par);
             surround(tail) = 0;
         }
         /* end mathskip code */
         if (dir_math_save) {
-            tail_append(new_dir(math_direction));
+            tail_append(new_dir(math_direction_par));
         }
         run_mlist_to_hlist(p, (mode > 0), text_style);
         vlink(tail) = vlink(temp_head);
@@ -2458,17 +2443,17 @@ void after_math(void)
             tail = vlink(tail);
         }
         if (dir_math_save) {
-            tail_append(new_dir(math_direction - dir_swap));
+            tail_append(new_dir(math_direction_par - dir_swap));
         }
         dir_math_save = false;
-        tail_append(new_math(math_surround, after));
+        tail_append(new_math(math_surround_par, after));
         /* begin mathskip code */
-        if (! glue_is_zero(math_skip)) {
-            copy_glue_values(tail,math_skip);
+        if (! glue_is_zero(math_skip_par)) {
+            copy_glue_values(tail,math_skip_par);
             surround(tail) = 0;
         }
         /* end mathskip code */
-        space_factor = 1000;
+        space_factor_par = 1000;
         unsave_math();
     } else {
         if (a == null) {
@@ -2498,12 +2483,12 @@ void finish_display_alignment(pointer p, pointer q, halfword saved_prevdepth)
         check_display_math_end();
     }
     pop_nest();
-    tail_append(new_penalty(int_par(pre_display_penalty_code)));
+    tail_append(new_penalty(pre_display_penalty_par));
     inject_display_skip_before(above_display_skip_code);
     vlink(tail) = p;
     if (p != null)
         tail = q;
-    tail_append(new_penalty(int_par(post_display_penalty_code)));
+    tail_append(new_penalty(post_display_penalty_par));
     inject_display_skip_after(below_display_skip_code);
     cur_list.prev_depth_field = saved_prevdepth;
     resume_after_display();
diff --git a/source/texk/web2c/luatexdir/tex/texnodes.h b/source/texk/web2c/luatexdir/tex/texnodes.h
index 61e2900544343dbfa6fff029372cc84f30061254..6650d17f41091ed70259fdaedbaeddb146e70f69 100644
--- a/source/texk/web2c/luatexdir/tex/texnodes.h
+++ b/source/texk/web2c/luatexdir/tex/texnodes.h
@@ -420,11 +420,17 @@ typedef enum {
 #  define last_known_node temp_node     /* used by \lastnodetype */
 
 #  define movement_node_size    3
-#  define expr_node_size        3
 #  define if_node_size          2
 #  define align_stack_node_size 6
 #  define nesting_node_size     2
 
+#  define expr_node_size        3
+#  define expr_type(A)          type((A)+1)
+#  define expr_state(A)         subtype((A)+1)  /* enum defined in scanning.w */
+#  define expr_e_field(A)       vlink((A)+1)    /* saved expression so far */
+#  define expr_t_field(A)       vlink((A)+2)    /* saved term so far */
+#  define expr_n_field(A)       vinfo((A)+2)    /* saved numerator */
+
 #  define span_node_size        3
 #  define span_span(a)          vlink((a)+1)
 #  define span_link(a)          vinfo((a)+1)
@@ -947,7 +953,10 @@ typedef enum {
 #  define var_mem_stat_max (end_point+glyph_node_size-1)
 
 #  define stretching 1
-#  define shrinking 2
+#  define shrinking  2
+
+#  define last_normal_node  shape_node
+#  define last_whatsit_node pdf_restore_node
 
 #  define is_running(A) ((A)==null_flag)        /* tests for a running dimension */
 
@@ -981,11 +990,6 @@ extern int lua_properties_enabled ;
 extern int lua_properties_level ;
 extern int lua_properties_use_metatable ;
 
-#define local_inter_line_penalty int_par(local_inter_line_penalty_code)
-#define local_broken_penalty int_par(local_broken_penalty_code)
-#define local_left_box equiv(local_left_box_base)
-#define local_right_box equiv(local_right_box_base)
-
 extern halfword make_local_par_node(int mode);
 
 #endif
diff --git a/source/texk/web2c/luatexdir/tex/texnodes.w b/source/texk/web2c/luatexdir/tex/texnodes.w
index 16f00977205b201a20fcb028f17e91937aba434f..6bfa14f2356ae1fad6a6961c37fe6d46513d9bef 100644
--- a/source/texk/web2c/luatexdir/tex/texnodes.w
+++ b/source/texk/web2c/luatexdir/tex/texnodes.w
@@ -33,16 +33,8 @@ makes no sense, not even to make it configureable. There is a little more memory
 used but that is neglectable compared to other memory usage.
 
 @c
-#define attribute(A) eqtb[attribute_base+(A)].cint
-
-#define uc_hyph int_par(uc_hyph_code)
-#define cur_lang int_par(cur_lang_code)
-#define left_hyphen_min int_par(left_hyphen_min_code)
-#define right_hyphen_min int_par(right_hyphen_min_code)
-
-#define MAX_CHAIN_SIZE 13 /* why not a bit larger */
-
-#define CHECK_NODE_USAGE 1 /* this triggers checking */
+#define MAX_CHAIN_SIZE   13 /* why not a bit larger */
+#define CHECK_NODE_USAGE  1 /* this triggers checking */
 
 memory_word *volatile varmem = NULL;
 
@@ -61,8 +53,8 @@ int fix_node_lists = 1; /* used in font and lang */
 
 halfword slow_get_node(int s);  /* defined below */
 
-#define fake_node 100
-#define fake_node_size 2
+#define fake_node       100
+#define fake_node_size  2
 #define fake_node_name "fake"
 
 #define variable_node_size 2
@@ -144,18 +136,6 @@ const char *node_fields_noad[] = {
     "attr", "nucleus", "sub", "sup", NULL
 };
 
-#define node_fields_ord     node_fields_noad
-#define node_fields_op      node_fields_noad
-#define node_fields_bin     node_fields_noad
-#define node_fields_rel     node_fields_noad
-#define node_fields_open    node_fields_noad
-#define node_fields_close   node_fields_noad
-#define node_fields_punct   node_fields_noad
-#define node_fields_inner   node_fields_noad
-#define node_fields_under   node_fields_noad
-#define node_fields_over    node_fields_noad
-#define node_fields_vcenter node_fields_noad
-
 const char *node_fields_style[] = {
     "attr", "style", NULL
 };
@@ -342,7 +322,7 @@ node_info node_data[] = { /* the last entry in a row is the etex number */
     { unset_node,          box_node_size,         node_fields_unset,                         "unset",          14 },
     { style_node,          style_node_size,       node_fields_style,                         "style",          15 },
     { choice_node,         style_node_size,       node_fields_choice,                        "choice",         15 },
-    { simple_noad,         noad_size,             node_fields_ord,                           "noad",           15 },
+    { simple_noad,         noad_size,             node_fields_noad,                          "noad",           15 },
     { radical_noad,        radical_noad_size,     node_fields_radical,                       "radical",        15 },
     { fraction_noad,       fraction_noad_size,    node_fields_fraction,                      "fraction",       15 },
     { accent_noad,         accent_noad_size,      node_fields_accent,                        "accent",         15 },
@@ -377,8 +357,6 @@ node_info node_data[] = { /* the last entry in a row is the etex number */
     { -1,                 -1,                     NULL,                                      NULL,             -1 },
 };
 
-#define last_normal_node shape_node
-
 const char *node_subtypes_pdf_destination[] = {
     "xyz", "fit", "fith", "fitv", "fitb", "fitbh", "fitbv", "fitr", NULL
 };
@@ -913,7 +891,7 @@ halfword new_node(int i, int j)
         default:
             break;
     }
-    if (int_par(synctex_code)) {
+    if (synctex_par) {
         /* handle synctex extension */
         switch (i) {
             case math_node:
@@ -1114,7 +1092,7 @@ halfword copy_node(const halfword p)
 
     (void) memcpy((void *) (varmem + r), (void *) (varmem + p), (sizeof(memory_word) * (unsigned) i));
 
-    if (int_par(synctex_code)) {
+    if (synctex_par) {
         /* handle synctex extension */
         switch (type(p)) {
             case math_node:
@@ -2869,7 +2847,7 @@ void show_node_list(int p)
     while (p != null) {
         print_ln();
         print_current_string(); /* display the nesting history */
-        if (int_par(tracing_online_code) < -2)
+        if (tracing_online_par < -2)
             print_int(p);
         incr(n);
         if (n > breadth_max) {  /* time to stop */
@@ -3350,7 +3328,7 @@ The |subtype| field is set to |min_quarterword|, since that's the desired
 halfword new_null_box(void)
 {                               /* creates a new box node */
     halfword p = new_node(hlist_node, min_quarterword);
-    box_dir(p) = text_direction;
+    box_dir(p) = text_direction_par;
     return p;
 }
 
@@ -3467,7 +3445,7 @@ halfword new_char(int f, int c)
     set_to_character(p);
     font(p) = f;
     character(p) = c;
-    lang_data(p) = make_lang_data(uc_hyph, cur_lang, left_hyphen_min, right_hyphen_min);
+    lang_data(p) = make_lang_data(uc_hyph_par, cur_lang_par, left_hyphen_min_par, right_hyphen_min_par);
     return p;
 }
 
@@ -3525,7 +3503,7 @@ not chosen.
 halfword new_disc(void)
 {                               /* creates an empty |disc_node| */
     halfword p = new_node(disc_node, 0);
-    disc_penalty(p) = int_par(hyphen_penalty_code);
+    disc_penalty(p) = hyphen_penalty_par;
     return p;
 }
 
@@ -3748,19 +3726,19 @@ halfword make_local_par_node(int mode)
     int callback_id;
     halfword q;
     halfword p = new_node(local_par_node,0);
-    local_pen_inter(p) = local_inter_line_penalty;
-    local_pen_broken(p) = local_broken_penalty;
-    if (local_left_box != null) {
-        q = copy_node_list(local_left_box);
+    local_pen_inter(p) = local_inter_line_penalty_par;
+    local_pen_broken(p) = local_broken_penalty_par;
+    if (local_left_box_par != null) {
+        q = copy_node_list(local_left_box_par);
         local_box_left(p) = q;
-        local_box_left_width(p) = width(local_left_box);
+        local_box_left_width(p) = width(local_left_box_par);
     }
-    if (local_right_box != null) {
-        q = copy_node_list(local_right_box);
+    if (local_right_box_par != null) {
+        q = copy_node_list(local_right_box_par);
         local_box_right(p) = q;
-        local_box_right_width(p) = width(local_right_box);
+        local_box_right_width(p) = width(local_right_box_par);
     }
-    local_par_dir(p) = par_direction;
+    local_par_dir(p) = par_direction_par;
     /* callback with node passed */
     callback_id = callback_defined(insert_local_par_callback);
     if (callback_id > 0) {
diff --git a/source/texk/web2c/luatexdir/tex/textoken.h b/source/texk/web2c/luatexdir/tex/textoken.h
index d2174beb370498bd431d358dde1e19b2825c80fd..9a9ef501cf6685757df1cb1c678e88ce5182d7c0 100644
--- a/source/texk/web2c/luatexdir/tex/textoken.h
+++ b/source/texk/web2c/luatexdir/tex/textoken.h
@@ -137,8 +137,6 @@ extern int get_char_cat_code(int);
 */
 
 # define no_expand_flag special_char
-# define end_line_char int_par(end_line_char_code)
-# define end_line_char_inactive ((end_line_char < 0) || (end_line_char > 127))
 
 extern halfword par_loc;
 extern halfword par_token;
diff --git a/source/texk/web2c/luatexdir/tex/textoken.w b/source/texk/web2c/luatexdir/tex/textoken.w
index 641734a82fb8741c75cb8c1567df5bd26eeb03ce..8f44f686641ba0e9368fa3f9d70390324e4a174c 100644
--- a/source/texk/web2c/luatexdir/tex/textoken.w
+++ b/source/texk/web2c/luatexdir/tex/textoken.w
@@ -22,17 +22,6 @@
 #include "ptexlib.h"
 
 @ @c
-#define pausing int_par(pausing_code)
-#define cat_code_table int_par(cat_code_table_code)
-#define tracing_nesting int_par(tracing_nesting_code)
-#define suppress_outer_error int_par(suppress_outer_error_code)
-#define suppress_mathpar_error int_par(suppress_mathpar_error_code)
-
-
-#define every_eof equiv(every_eof_loc)
-#define box(A) equiv(box_base+(A))
-#define toks(A) equiv(toks_base+(A))
-
 #define detokenized_line() (line_catcode_table==NO_CAT_TABLE)
 
 /*
@@ -42,13 +31,13 @@
     else if (line_catcode_table!=DEFAULT_CAT_TABLE) \
       a=get_cat_code(line_catcode_table,b); \
     else \
-      a=get_cat_code(cat_code_table,b); \
+      a=get_cat_code(cat_code_table_par,b); \
   } while (0)
 */
 
 #define do_get_cat_code(a,b) do { \
     if (line_catcode_table==DEFAULT_CAT_TABLE) \
-      a=get_cat_code(cat_code_table,b); \
+      a=get_cat_code(cat_code_table_par,b); \
     else if (line_catcode_table>-0xFF) \
       a=get_cat_code(line_catcode_table,b); \
     else \
@@ -766,7 +755,7 @@ void firm_up_the_line(void)
 {
     int k;                      /* an index into |buffer| */
     ilimit = last;
-    if (pausing > 0) {
+    if (pausing_par > 0) {
         if (interaction > nonstop_mode) {
             wake_up_terminal();
             print_ln();
@@ -795,7 +784,7 @@ void check_outer_validity(void)
 {
     halfword p;                 /* points to inserted token list */
     halfword q;                 /* auxiliary pointer */
-    if (suppress_outer_error)
+    if (suppress_outer_error_par)
         return;
     if (scanner_status != normal) {
         deletions_allowed = false;
@@ -980,7 +969,7 @@ static boolean get_next_file(void)
             case skip_blanks + escape_cmd:
                 /* Scan a control sequence ...; */
                 istate = (unsigned char) scan_control_sequence();
-                if (! suppress_outer_error && cur_cmd >= outer_call_cmd)
+                if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd)
                     check_outer_validity();
                 break;
             case mid_line + active_char_cmd:
@@ -991,7 +980,7 @@ static boolean get_next_file(void)
                 cur_cmd = eq_type(cur_cs);
                 cur_chr = equiv(cur_cs);
                 istate = mid_line;
-                if (! suppress_outer_error && cur_cmd >= outer_call_cmd)
+                if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd)
                     check_outer_validity();
                 break;
             case mid_line + sup_mark_cmd:
@@ -1041,7 +1030,7 @@ static boolean get_next_file(void)
                 cur_cs = par_loc;
                 cur_cmd = eq_type(cur_cs);
                 cur_chr = equiv(cur_cs);
-                if (! suppress_outer_error && cur_cmd >= outer_call_cmd)
+                if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd)
                     check_outer_validity();
                 break;
             case skip_blanks + left_brace_cmd:
@@ -1141,7 +1130,7 @@ static boolean get_next_file(void)
             switch (c-new_line) {
                 case escape_cmd:
                     istate = (unsigned char) scan_control_sequence();
-                    if (! suppress_outer_error && cur_cmd >= outer_call_cmd)
+                    if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd)
                         check_outer_validity();
                     return true;
                 case left_brace_cmd:
@@ -1164,7 +1153,7 @@ static boolean get_next_file(void)
                     cur_cs = par_loc;
                     cur_cmd = eq_type(cur_cs);
                     cur_chr = equiv(cur_cs);
-                    if (! suppress_outer_error && cur_cmd >= outer_call_cmd)
+                    if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd)
                         check_outer_validity();
                     return true;
                 case mac_param_cmd:
@@ -1196,7 +1185,7 @@ static boolean get_next_file(void)
                     cur_cmd = eq_type(cur_cs);
                     cur_chr = equiv(cur_cs);
                     istate = mid_line;
-                    if (! suppress_outer_error && cur_cmd >= outer_call_cmd)
+                    if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd)
                         check_outer_validity();
                     return true;
                 case comment_cmd:
@@ -1214,7 +1203,7 @@ static boolean get_next_file(void)
                 case escape_cmd:
                     /* Scan a control sequence ...; */
                     istate = (unsigned char) scan_control_sequence();
-                    if (! suppress_outer_error && cur_cmd >= outer_call_cmd)
+                    if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd)
                         check_outer_validity();
                     return true;
                 case left_brace_cmd:
@@ -1262,7 +1251,7 @@ static boolean get_next_file(void)
                     cur_cmd = eq_type(cur_cs);
                     cur_chr = equiv(cur_cs);
                     istate = mid_line;
-                    if (! suppress_outer_error && cur_cmd >= outer_call_cmd)
+                    if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd)
                         check_outer_validity();
                     return true;
                 case comment_cmd:
@@ -1281,7 +1270,7 @@ static boolean get_next_file(void)
             switch (c-mid_line) {
                 case escape_cmd:
                     istate = (unsigned char) scan_control_sequence();
-                    if (! suppress_outer_error && cur_cmd >= outer_call_cmd)
+                    if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd)
                         check_outer_validity();
                     return true;
                 case left_brace_cmd:
@@ -1334,7 +1323,7 @@ static boolean get_next_file(void)
                     cur_cmd = eq_type(cur_cs);
                     cur_chr = equiv(cur_cs);
                     istate = mid_line;
-                    if (! suppress_outer_error && cur_cmd >= outer_call_cmd)
+                    if (! suppress_outer_error_par && cur_cmd >= outer_call_cmd)
                         check_outer_validity();
                     return true;
                 case comment_cmd:
@@ -1694,11 +1683,11 @@ one more branch.
                     line_catcode_table = DEFAULT_CAT_TABLE;
                     if ((iname == 19) && (pseudo_lines(pseudo_files) == null))
                         inhibit_eol = true;
-                } else if ((every_eof != null) && !eof_seen[iindex]) {
+                } else if ((every_eof_par != null) && !eof_seen[iindex]) {
                     ilimit = first - 1;
                     eof_seen[iindex] = true; /* fake one empty line */
                     if (iname != 19)
-                        begin_token_list(every_eof, every_eof_text);
+                        begin_token_list(every_eof_par, every_eof_text);
                     return next_line_restart;
                 } else {
                     force_eof = true;
@@ -1721,10 +1710,10 @@ one more branch.
                     if (lua_input_ln(cur_file, 0, true)) { /* not end of file */
                         firm_up_the_line(); /* this sets |ilimit| */
                         line_catcode_table = DEFAULT_CAT_TABLE;
-                    } else if ((every_eof != null) && (!eof_seen[iindex])) {
+                    } else if ((every_eof_par != null) && (!eof_seen[iindex])) {
                         ilimit = first - 1;
                         eof_seen[iindex] = true; /* fake one empty line */
-                        begin_token_list(every_eof, every_eof_text);
+                        begin_token_list(every_eof_par, every_eof_text);
                         return next_line_restart;
                     } else {
                         force_eof = true;
@@ -1733,7 +1722,7 @@ one more branch.
             }
         }
         if (force_eof) {
-            if (tracing_nesting > 0)
+            if (tracing_nesting_par > 0)
                 if ((grp_stack[in_open] != cur_boundary) || (if_stack[in_open] != cond_ptr))
                     if (!((iname == 19) || (iname == 21))) {
                         /* give warning for some unfinished groups and/or conditionals */
@@ -1749,7 +1738,7 @@ one more branch.
                 end_file_reading();
             } else {
                 end_file_reading();
-                if (! suppress_outer_error)
+                if (! suppress_outer_error_par)
                     check_outer_validity();
             }
             return next_line_restart;
@@ -1757,7 +1746,7 @@ one more branch.
         if (inhibit_eol || end_line_char_inactive)
             ilimit--;
         else
-            buffer[ilimit] = (packed_ASCII_code) end_line_char;
+            buffer[ilimit] = (packed_ASCII_code) end_line_char_par;
         first = ilimit + 1;
         iloc = istart; /* ready to read */
     } else {
@@ -1788,7 +1777,7 @@ one more branch.
             if (end_line_char_inactive)
                 ilimit--;
             else
-                buffer[ilimit] = (packed_ASCII_code) end_line_char;
+                buffer[ilimit] = (packed_ASCII_code) end_line_char_par;
             first = ilimit + 1;
             iloc = istart;
         } else {
@@ -1829,7 +1818,7 @@ static boolean get_next_tokenlist(void)
                     cur_chr = no_expand_flag;
                     return true;
                 }
-            } else if (! suppress_outer_error) {
+            } else if (! suppress_outer_error_par) {
                 check_outer_validity();
             }
         }
@@ -3154,7 +3143,7 @@ void read_toks(int n, halfword r, halfword j)
         if (end_line_char_inactive)
             decr(ilimit);
         else
-            buffer[ilimit] = (packed_ASCII_code) int_par(end_line_char_code);
+            buffer[ilimit] = (packed_ASCII_code) end_line_char_par;
         first = ilimit + 1;
         iloc = istart;
         istate = new_line;
@@ -3285,7 +3274,7 @@ char *tokenlist_to_cstring(int pp, int inhibit_par, int *siz)
     ret = xmalloc(alloci);
     p = token_link(p);          /* skip refcount */
     if (p != null) {
-        e = int_par(escape_char_code);
+        e = escape_char_par;
     }
     while (p != null) {
         if (p < (int) fix_mem_min || p > (int) fix_mem_end) {
diff --git a/source/texk/web2c/man/pdftex.man b/source/texk/web2c/man/pdftex.man
index d1b8ef5e2d6b56b077ac6a965484525aa0462210..4e1ae088a916550a9fac289cec13305bdc66e6de 100644
--- a/source/texk/web2c/man/pdftex.man
+++ b/source/texk/web2c/man/pdftex.man
@@ -379,7 +379,7 @@ If set, its value, taken to be in epoch-seconds, will be used for the
 timestamps in the PDF output, such as the CreationDate and ModDate keys.
 This is useful for making reproducible builds.
 .TP
-.B SOURCE_DATE_EPOCH_TEX_PRIMITIVES
+.B FORCE_SOURCE_DATE
 If set to the value "1", the time-related \*(TX primitives
 .RI ( \eyear ,
 .IR \emonth ,
diff --git a/source/texk/web2c/web2c/configure b/source/texk/web2c/web2c/configure
index 2817b9d8750616c482181b7a7025a070e18ca85f..303edcd11e8942451eb4471028419b03e39d4609 100755
--- a/source/texk/web2c/web2c/configure
+++ b/source/texk/web2c/web2c/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for Web2C Tools 2016.
+# Generated by GNU Autoconf 2.69 for Web2C Tools 2017/dev.
 #
 # Report bugs to <tex-k@tug.org>.
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='Web2C Tools'
 PACKAGE_TARNAME='web2c-tools'
-PACKAGE_VERSION='2016'
-PACKAGE_STRING='Web2C Tools 2016'
+PACKAGE_VERSION='2017/dev'
+PACKAGE_STRING='Web2C Tools 2017/dev'
 PACKAGE_BUGREPORT='tex-k@tug.org'
 PACKAGE_URL=''
 
@@ -1328,7 +1328,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Web2C Tools 2016 to adapt to many kinds of systems.
+\`configure' configures Web2C Tools 2017/dev to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1398,7 +1398,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Web2C Tools 2016:";;
+     short | recursive ) echo "Configuration of Web2C Tools 2017/dev:";;
    esac
   cat <<\_ACEOF
 
@@ -1521,7 +1521,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Web2C Tools configure 2016
+Web2C Tools configure 2017/dev
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2360,7 +2360,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Web2C Tools $as_me 2016, which was
+It was created by Web2C Tools $as_me 2017/dev, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -8045,7 +8045,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='web2c-tools'
- VERSION='2016'
+ VERSION='2017/dev'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -14574,7 +14574,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by Web2C Tools $as_me 2016, which was
+This file was extended by Web2C Tools $as_me 2017/dev, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -14640,7 +14640,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-Web2C Tools config.status 2016
+Web2C Tools config.status 2017/dev
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/source/utils/configure b/source/utils/configure
index 1eceafade3e49b8e23d5ee7dbb9125f09b6dcb39..f30f1a698a03c62d29731f7b0a340c26e4ea6903 100755
--- a/source/utils/configure
+++ b/source/utils/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for TeX Live utils 2016.
+# Generated by GNU Autoconf 2.69 for TeX Live utils 2017/dev.
 #
 # Report bugs to <tex-k@tug.org>.
 #
@@ -579,8 +579,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='TeX Live utils'
 PACKAGE_TARNAME='tex-live-utils'
-PACKAGE_VERSION='2016'
-PACKAGE_STRING='TeX Live utils 2016'
+PACKAGE_VERSION='2017/dev'
+PACKAGE_STRING='TeX Live utils 2017/dev'
 PACKAGE_BUGREPORT='tex-k@tug.org'
 PACKAGE_URL=''
 
@@ -1316,7 +1316,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures TeX Live utils 2016 to adapt to many kinds of systems.
+\`configure' configures TeX Live utils 2017/dev to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1386,7 +1386,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of TeX Live utils 2016:";;
+     short | recursive ) echo "Configuration of TeX Live utils 2017/dev:";;
    esac
   cat <<\_ACEOF
 
@@ -1576,7 +1576,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-TeX Live utils configure 2016
+TeX Live utils configure 2017/dev
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1677,7 +1677,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by TeX Live utils $as_me 2016, which was
+It was created by TeX Live utils $as_me 2017/dev, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -4509,7 +4509,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='tex-live-utils'
- VERSION='2016'
+ VERSION='2017/dev'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -5421,7 +5421,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by TeX Live utils $as_me 2016, which was
+This file was extended by TeX Live utils $as_me 2017/dev, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5478,7 +5478,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-TeX Live utils config.status 2016
+TeX Live utils config.status 2017/dev
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/source/version.ac b/source/version.ac
index 6bb7b53fae573370227e5f2ebfe99886dbd84318..fbccd710e12f7e0791779137babf2f25f77d9bd7 100644
--- a/source/version.ac
+++ b/source/version.ac
@@ -1,4 +1,4 @@
-dnl $Id: version.ac 39950 2016-03-06 21:56:59Z karl $
+dnl $Id: version.ac 41571 2016-06-29 23:09:13Z karl $
 dnl   Copyright 2016 Karl Berry <tex-live@tug.org>
 dnl   Copyright 2010-2015 Peter Breitenlohner <tex-live@tug.org>
 dnl
@@ -9,4 +9,4 @@ dnl
 dnl --------------------------------------------------------
 dnl
 dnl  m4-include this file to define the current TeX Live version
-m4_define([tex_live_version], [2016])
+m4_define([tex_live_version], [2017/dev])