summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/strc-ref.lua
diff options
context:
space:
mode:
authorMojca Miklavec <mojca.miklavec@gmail.com>2012-05-24 20:38:29 +0000
committerMojca Miklavec <mojca.miklavec@gmail.com>2012-05-24 20:38:29 +0000
commit8b6aa4917f960304df746f97e8861cc422c7990a (patch)
tree78288b0dd7fc5c159ec1df6c6ddc1c00f72b5bbf /Master/texmf-dist/tex/context/base/strc-ref.lua
parent2e0afd608a5d9a2bd37c7b1db5fa2f1b4d2ce976 (diff)
ConTeXt 2012.05.24 19:36
git-svn-id: svn://tug.org/texlive/trunk@26637 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-ref.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/strc-ref.lua48
1 files changed, 39 insertions, 9 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-ref.lua b/Master/texmf-dist/tex/context/base/strc-ref.lua
index 8a478a4e6e7..092babfaed6 100644
--- a/Master/texmf-dist/tex/context/base/strc-ref.lua
+++ b/Master/texmf-dist/tex/context/base/strc-ref.lua
@@ -261,17 +261,28 @@ references.setcomponent = setcomponent
function references.set(kind,prefix,tag,data)
-- setcomponent(data)
- local pd = tobesaved[prefix]
+ local pd = tobesaved[prefix] -- nicer is a metatable
if not pd then
pd = { }
tobesaved[prefix] = pd
end
+ local n = 0
for ref in gmatch(tag,"[^,]+") do
if ref ~= "" then
- pd[ref] = data
- context.dofinishsomereference(kind,prefix,ref)
+ if pd[ref] then
+ if prefix and prefix ~= "" then
+ report_references("redundant reference: %q in namespace %q",ref,prefix)
+ else
+ report_references("redundant reference %q",ref)
+ end
+ else
+ n = n + 1
+ pd[ref] = data
+ context.dofinishsomereference(kind,prefix,ref)
+ end
end
end
+ return n > 0
end
function references.enhance(prefix,tag)
@@ -348,14 +359,22 @@ local function register_from_lists(collected,derived,pages,sections)
if reference ~= "" then
local kind, realpage = m.kind, r.realpage
if kind and realpage then
- local d = derived[prefix] if not d then d = { } derived[prefix] = d end
-local c = derived[component] if not c then c = { } derived[component] = c end
+ local d = derived[prefix]
+ if not d then
+ d = { }
+ derived[prefix] = d
+ end
+ local c = derived[component]
+ if not c then
+ c = { }
+ derived[component] = c
+ end
local t = { kind, i, entry }
for s in gmatch(reference,"%s*([^,]+)") do
if trace_referencing then
report_references("list entry %s provides %s reference '%s' on realpage %s",i,kind,s,realpage)
end
-c[s] = c[s] or t -- share them
+ c[s] = c[s] or t -- share them
d[s] = d[s] or t -- share them
g[s] = g[s] or t -- first wins
end
@@ -768,12 +787,14 @@ table.setmetatableindex(externals,function(t,k) -- either or not automatically
return false
end)
-local productdata = {
+local productdata = allocate {
productreferences = { },
componentreferences = { },
components = { },
}
+references.productdata = productdata
+
local function loadproductreferences(productname,componentname,utilitydata)
local struc = utilitydata.structures
if struc then
@@ -923,6 +944,11 @@ local function loadproductcomponents(product,component,utilitydata)
productdata.components = componentlist(job and job.structure and job.structure.collected) or { }
end
+references.registerinitializer(function(tobesaved,collected)
+ -- not that much related to tobesaved or collected
+ productdata.components = componentlist(job.structure.collected) or { }
+end)
+
function structures.references.loadpresets(product,component) -- we can consider a special components hash
if product and component and product~= "" and component ~= "" and not productdata.product then -- maybe: productdata.filename ~= filename
productdata.product = product
@@ -1294,6 +1320,7 @@ local function identify_inner_or_outer(set,var,i)
end
local components = job.structure.components
+
if components then
for i=1,#components do
local component = components[i]
@@ -1585,8 +1612,11 @@ function references.setinternalreference(prefix,tag,internal,view) -- needs chec
end
function references.setandgetattribute(kind,prefix,tag,data,view) -- maybe do internal automatically here
- references.set(kind,prefix,tag,data)
- texcount.lastdestinationattribute = references.setinternalreference(prefix,tag,nil,view) or -0x7FFFFFFF
+ if references.set(kind,prefix,tag,data) then
+ texcount.lastdestinationattribute = references.setinternalreference(prefix,tag,nil,view) or unsetvalue
+ else
+ texcount.lastdestinationattribute = unsetvalue
+ end
end
function references.getinternalreference(n) -- n points into list (todo: registers)