From 537e1c0954f0745adb3fc79c762ae0e7b1bd213a Mon Sep 17 00:00:00 2001
From: Hans Hagen <pragma@wxs.nl>
Date: Thu, 9 Jan 2014 18:27:00 +0100
Subject: beta 2014.01.09 18:27

---
 tex/context/base/back-exp.lua                      |   2 +-
 tex/context/base/cont-new.mkiv                     |   2 +-
 tex/context/base/context-version.pdf               | Bin 4119 -> 4082 bytes
 tex/context/base/context.mkiv                      |   2 +-
 tex/context/base/lang-rep.lua                      |  20 ++++++-----
 tex/context/base/lang-wrd.lua                      |   9 +++--
 tex/context/base/lpdf-tag.lua                      |  39 +++++++++++++++++----
 tex/context/base/node-acc.lua                      |  22 +++++++-----
 tex/context/base/page-mix.lua                      |   8 ++---
 tex/context/base/status-files.pdf                  | Bin 24607 -> 24604 bytes
 tex/context/base/status-lua.pdf                    | Bin 228424 -> 228478 bytes
 tex/context/base/trac-jus.lua                      |   7 ++--
 tex/context/base/typo-mar.lua                      |   2 +-
 tex/context/base/typo-spa.lua                      |   1 +
 tex/context/base/x-set-11.mkiv                     |  15 +++++---
 tex/generic/context/luatex/luatex-fonts-merged.lua |   2 +-
 16 files changed, 87 insertions(+), 44 deletions(-)

diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua
index dedfc22c0..cd499abe7 100644
--- a/tex/context/base/back-exp.lua
+++ b/tex/context/base/back-exp.lua
@@ -2097,7 +2097,7 @@ local function collectresults(head,list) -- is last used (we also have currentat
             if kern > 0 then
                 local limit = threshold
                 if p and getid(p) == glyph_code then
-                    limit = fontquads[p.font] / 4
+                    limit = fontquads[getfont(p)] / 4
                 end
                 if kern > limit then
                     if last and not somespace[currentcontent[nofcurrentcontent]] then
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index ab1e7369d..0f072a1ae 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\newcontextversion{2014.01.08 15:36}
+\newcontextversion{2014.01.09 18:27}
 
 %D This file is loaded at runtime, thereby providing an excellent place for
 %D hacks, patches, extensions and new features.
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 3d07c88cf..6f4f178a5 100644
Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 8e79041ff..3996e6269 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -28,7 +28,7 @@
 %D up and the dependencies are more consistent.
 
 \edef\contextformat {\jobname}
-\edef\contextversion{2014.01.08 15:36}
+\edef\contextversion{2014.01.09 18:27}
 \edef\contextkind   {beta}
 
 %D For those who want to use this:
diff --git a/tex/context/base/lang-rep.lua b/tex/context/base/lang-rep.lua
index 3dec9503e..fb136b551 100644
--- a/tex/context/base/lang-rep.lua
+++ b/tex/context/base/lang-rep.lua
@@ -28,9 +28,9 @@ local getattr            = nuts.getattr
 local getid              = nuts.getid
 local getchar            = nuts.getchar
 
-local insert_node_before = nodes.insert_before
-local remove_node        = nodes.remove
-local copy_node          = nodes.copy
+local insert_node_before = nuts.insert_before
+local remove_node        = nuts.remove
+local copy_node          = nuts.copy
 
 local texsetattribute    = tex.setattribute
 local unsetvalue         = attributes.unsetvalue
@@ -58,12 +58,13 @@ end)
 
 local function add(root,word,replacement)
     local list = utfsplit(word,true)
-    for i=1,#list do
+    local size = #list
+    for i=1,size do
         local l = utfbyte(list[i])
         if not root[l] then
             root[l] = { }
         end
-        if i == #list then
+        if i == size then
             local newlist = utfsplit(replacement,true)
             for i=1,#newlist do
                 newlist[i] = utfbyte(newlist[i])
@@ -71,7 +72,7 @@ local function add(root,word,replacement)
             root[l].final = {
                 word        = word,
                 replacement = replacement,
-                oldlength   = #list,
+                oldlength   = size,
                 newcodes    = newlist,
             }
         end
@@ -124,10 +125,11 @@ local function hit(a,head)
 end
 
 function replacements.handler(head)
-    local current = tonut(head)
+    head = tonut(head)
+    local current = head
     local done    = false
     while current do
-        if current.id == glyph_code then
+        if getid(current) == glyph_code then
             local a = getattr(current,a_replacements)
             if a then
                 local last, final = hit(a,current)
@@ -141,7 +143,7 @@ function replacements.handler(head)
                     if oldlength == newlength then -- #old == #new
                         for i=1,newlength do
                             setfield(current,"char",newcodes[i])
-                            current = current.next
+                            current = getnext(current)
                         end
                     elseif oldlength < newlength then -- #old < #new
                         for i=1,newlength-oldlength do
diff --git a/tex/context/base/lang-wrd.lua b/tex/context/base/lang-wrd.lua
index 11d99976e..5fc23757e 100644
--- a/tex/context/base/lang-wrd.lua
+++ b/tex/context/base/lang-wrd.lua
@@ -34,6 +34,7 @@ local getnext         = nuts.getnext
 local getid           = nuts.getid
 local getsubtype      = nuts.getsubtype
 local getchar         = nuts.getchar
+local setattr         = nuts.setattr
 
 local traverse_nodes  = nuts.traverse
 
@@ -186,6 +187,8 @@ local enabled    = false
 function words.check(head)
     if enabled then
         return methods[wordmethod](head)
+    elseif not head then
+        return head, false
     else
         return head, false
     end
@@ -217,7 +220,7 @@ table.setmetatableindex(cache, function(t,k) -- k == language, numbers[k] == tag
     else
         c = colist["word:" .. (numbers[k] or "unset")] or colist["word:unknown"]
     end
-    local v = c and function(n) n[a_color] = c end or false
+    local v = c and function(n) setattr(n,a_color,c) end or false
     t[k] = v
     return v
 end)
@@ -236,7 +239,7 @@ end
 
 methods[1] = function(head)
     for n in traverse_nodes(head) do
-        n[a_color] = unsetvalue -- hm, not that selective (reset color)
+        setattr(n,a_color,unsetvalue) -- hm, not that selective (reset color)
     end
     return mark_words(head,sweep)
 end
@@ -337,7 +340,7 @@ end
 
 methods[3] = function(head)
     for n in traverse_nodes(head) do
-        n[a_color] = unsetvalue
+        setattr(n,a_color,unsetvalue)
     end
     return mark_words(head,sweep)
 end
diff --git a/tex/context/base/lpdf-tag.lua b/tex/context/base/lpdf-tag.lua
index 83315da07..37a640225 100644
--- a/tex/context/base/lpdf-tag.lua
+++ b/tex/context/base/lpdf-tag.lua
@@ -36,10 +36,6 @@ local pdfpagereference = lpdf.pagereference
 
 local texgetcount      = tex.getcount
 
-local nodepool         = nodes.pool
-
-local pdfliteral       = nodepool.pdfliteral
-
 local nodecodes        = nodes.nodecodes
 
 local hlist_code       = nodecodes.hlist
@@ -53,9 +49,13 @@ local nuts             = nodes.nuts
 local tonut            = nuts.tonut
 local tonode           = nuts.tonode
 
+local nodepool         = nuts.pool
+local pdfliteral       = nodepool.pdfliteral
+
 local getid            = nuts.getid
 local getattr          = nuts.getattr
 local getprev          = nuts.getprev
+local getnext          = nuts.getnext
 local getlist          = nuts.getlist
 local setfield         = nuts.setfield
 
@@ -213,7 +213,29 @@ local function makecontent(parent,start,stop,slist,id)
     --
     local bliteral = pdfliteral(format("/%s <</MCID %s>>BDC",tag,last))
     local eliteral = pdfliteral("EMC")
-    --
+-- if false
+--     local prev = getprev(start)
+--     if prev then
+--         setfield(prev,"next",bliteral)
+--         setfield(bliteral,"prev",prev)
+--     end
+--     setfield(start,"prev",bliteral)
+--     setfield(bliteral,"next",start)
+--     --
+--     local next = getnext(stop)
+--     if next then
+--         setfield(next,"prev",eliteral)
+--         setfield(eliteral,"next",next)
+--     end
+--     setfield(stop,"next",eliteral)
+--     setfield(eliteral,"prev",stop)
+--     --
+--     if slist and getlist(slist) == start then
+--         setfield(slist,"list",bliteral)
+--     elseif not prev then
+--         report_tags("this can't happen: injection in front of nothing")
+--     end
+-- else
     if slist and getlist(slist) == start then
         setfield(slist,"list",bliteral)
     elseif not getprev(start) then
@@ -222,6 +244,7 @@ local function makecontent(parent,start,stop,slist,id)
     --
     insert_before(start,start,bliteral)
     insert_after(stop,stop,eliteral)
+-- end
     --
     index = index + 1
     list[index] = parent.pref
@@ -269,7 +292,8 @@ function nodeinjections.addtags(head)
     -- no need to adapt head, as we always operate on lists
     level, last, ranges, range = 0, nil, { }, nil
     initializepage()
-    collectranges(tonut(head))
+	head = tonut(head)
+    collectranges(head)
     if trace_tags then
         for i=1,#ranges do
             local range = ranges[i]
@@ -296,7 +320,7 @@ function nodeinjections.addtags(head)
         local b, e = makecontent(prev,start,stop,list,id)
         if start == head then
             report_tags("this can't happen: parent list gets tagged")
-            head = tonode(b)
+            head = b
         end
     end
     finishpage()
@@ -304,6 +328,7 @@ function nodeinjections.addtags(head)
     --
     -- injectspans(tonut(head)) -- does to work yet
     --
+    head = tonode(head)
     return head, true
 end
 
diff --git a/tex/context/base/node-acc.lua b/tex/context/base/node-acc.lua
index 6a1b986bc..59fa031bf 100644
--- a/tex/context/base/node-acc.lua
+++ b/tex/context/base/node-acc.lua
@@ -31,6 +31,8 @@ local copy_node      = nuts.copy
 local free_nodelist  = nuts.flush_list
 local insert_after   = nuts.insert_after
 
+local new_gluespec   = nuts.pool.gluespec -- temp hack 
+
 local glue_code      = nodecodes.glue
 local kern_code      = nodecodes.kern
 local glyph_code     = nodecodes.glyph
@@ -53,7 +55,8 @@ local function injectspaces(head)
         local id = getid(n)
         if id == glue_code then -- todo: check for subtype related to spacing (13/14 but most seems to be 0)
        -- if getfield(getfield(n,"spec"),"width") > 0 then -- threshold
-            if p and p_id == glyph_code then
+--          if p and p_id == glyph_code then
+            if p and getid(p) == glyph_code then
                 local g = copy_node(p)
                 local c = getfield(g,"components")
                 if c then -- it happens that we copied a ligature
@@ -61,16 +64,19 @@ local function injectspaces(head)
                     setfield(g,"components",nil)
                     setfield(g,"subtype",256)
                 end
-                -- p .. g
                 local a = getattr(n,a_characters)
-                local s = copy_node(getfield(n,"spec"))
+                -- local s = copy_node(getfield(n,"spec"))
+                -- this will be fixed in luatex but for now a temp hack (zero test)
+                local s = getfield(n,"spec")
+                s = s == 0 and new_gluespec(0) or copy_node(s)
+                --
                 setfield(g,"char",32)
-                insert_after(p,p,g)
-             -- setfield(p,"next",g)
-             -- setfield(g,"prev",p)
-             -- setfield(g,"next",n)
-             -- setfield(n,"prev",g)
                 setfield(n,"spec",s)
+             -- insert_after(p,p,g)
+                setfield(p,"next",g)
+                setfield(g,"prev",p)
+                setfield(g,"next",n)
+                setfield(n,"prev",g)
                 setfield(s,"width",getfield(s,"width") - getfield(g,"width"))
                 if a then
                     setattr(g,a_characters,a)
diff --git a/tex/context/base/page-mix.lua b/tex/context/base/page-mix.lua
index a7db58f82..dd182dd69 100644
--- a/tex/context/base/page-mix.lua
+++ b/tex/context/base/page-mix.lua
@@ -683,10 +683,10 @@ function mixedcolumns.finalize(result)
                         local l = list[i]
                         local h = new_hlist()
                         t[i] = h
-                        setfield(h,"list",l.head)
-                        setfield(h,"height",l.height)
-                        setfield(h,"depth",l.depth)
-                        l.head = nil
+                        setfield(h,"list",getfield(l,"head"))
+                        setfield(h,"height",getfield(l,"height"))
+                        setfield(h,"depth",getfield(l,"depth"))
+                        setfield(l,"head",nil)
                     end
                     setfield(t[1],"prev",nil)  -- needs checking
                     setfield(t[#t],"next",nil) -- needs checking
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 7063ab6a5..33d7d13f2 100644
Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index b8fd428ea..28cd4d7bb 100644
Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ
diff --git a/tex/context/base/trac-jus.lua b/tex/context/base/trac-jus.lua
index d95e48816..00c871159 100644
--- a/tex/context/base/trac-jus.lua
+++ b/tex/context/base/trac-jus.lua
@@ -15,15 +15,16 @@ local a_alignstate        = attributes.private("alignstate")
 local a_justification     = attributes.private("justification")
 
 local nuts                = nodes.nuts
-local tonut               = tonut
+local tonut               = nuts.tonut
 
 local getfield            = nuts.getfield
 local setfield            = nuts.setfield
+local getlist             = nuts.getlist
 local getattr             = nuts.getattr
 local setattr             = nuts.setattr
 local setlist             = nuts.setlist
 
-local traverse_id         = nuts.travers_id
+local traverse_id         = nuts.traverse_id
 local get_list_dimensions = nuts.dimensions
 local linked_nodes        = nuts.linked
 local copy_node           = nuts.copy
@@ -77,7 +78,7 @@ function checkers.handler(head)
     for current in traverse_id(hlist_code,tonut(head)) do
         if getattr(current,a_justification) == 1 then
             setattr(current,a_justification,0)
-            local width = setfield(current,"width")
+            local width = getfield(current,"width")
             if width > 0 then
                 local list = getlist(current)
                 if list then
diff --git a/tex/context/base/typo-mar.lua b/tex/context/base/typo-mar.lua
index a41a409dd..17d96478d 100644
--- a/tex/context/base/typo-mar.lua
+++ b/tex/context/base/typo-mar.lua
@@ -250,7 +250,7 @@ local function showstore(store,banner,location)
     if next(store) then
         for i, si in table.sortedpairs(store) do
             local si =store[i]
-            report_margindata("%s: stored in %a at %s: %a => %s",banner,location,i,validstring(si.name,"no name"),nodes.toutf(si.box.list))
+            report_margindata("%s: stored in %a at %s: %a => %s",banner,location,i,validstring(si.name,"no name"),nodes.toutf(getlist(si.box)))
         end
     else
         report_margindata("%s: nothing stored in location %a",banner,location)
diff --git a/tex/context/base/typo-spa.lua b/tex/context/base/typo-spa.lua
index 039f7c81d..5cf9ab837 100644
--- a/tex/context/base/typo-spa.lua
+++ b/tex/context/base/typo-spa.lua
@@ -34,6 +34,7 @@ local getnext            = nuts.getnext
 local getprev            = nuts.getprev
 local getchar            = nuts.getchar
 local getid              = nuts.getid
+local getfont            = nuts.getfont
 local getattr            = nuts.getattr
 
 local setattr            = nuts.setattr
diff --git a/tex/context/base/x-set-11.mkiv b/tex/context/base/x-set-11.mkiv
index 1de683521..3f8d97b51 100644
--- a/tex/context/base/x-set-11.mkiv
+++ b/tex/context/base/x-set-11.mkiv
@@ -638,11 +638,16 @@
         \xmlflush{#1}
         \doifmode{interface:setup:defaults} {
             \ifx\currentSETUPhash\empty \else
-               \edef\currentSETUPvalue{\csname named\currentSETUPhash parameter\endcsname\empty{\xmlatt{#1}{name}}}
-               \ifx\currentSETUPvalue\empty \else
-                 =\space
-                 \detokenize\expandafter{\currentSETUPvalue}
-               \fi
+                \begingroup
+                    % todo, make a one level expansion of parameter
+                    \let\emwidth \relax
+                    \let\exheight\relax
+                    \edef\currentSETUPvalue{\csname named\currentSETUPhash parameter\endcsname\empty{\xmlatt{#1}{name}}}
+                    \ifx\currentSETUPvalue\empty \else
+                        =\space
+                        \detokenize\expandafter{\currentSETUPvalue}
+                    \fi
+                \endgroup
             \fi
         }
     \stopsecondSETUPcolumn
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index e36d72840..0b12aadc6 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
 -- merged file : luatex-fonts-merged.lua
 -- parent file : luatex-fonts.lua
--- merge date  : 01/08/14 15:36:15
+-- merge date  : 01/09/14 18:27:26
 
 do -- begin closure to overcome local limits and interference
 
-- 
cgit v1.2.3