summaryrefslogtreecommitdiff
path: root/tex/context/base/strc-reg.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/strc-reg.lua')
-rw-r--r--tex/context/base/strc-reg.lua85
1 files changed, 23 insertions, 62 deletions
diff --git a/tex/context/base/strc-reg.lua b/tex/context/base/strc-reg.lua
index b0d8a8a25..40cd3455b 100644
--- a/tex/context/base/strc-reg.lua
+++ b/tex/context/base/strc-reg.lua
@@ -7,41 +7,36 @@ if not modules then modules = { } end modules ['strc-reg'] = {
}
local next, type = next, type
+local texcount = tex.count
local format, gmatch = string.format, string.gmatch
local equal, concat, remove = table.are_equal, table.concat, table.remove
local utfchar = utf.char
local lpegmatch = lpeg.match
local allocate = utilities.storage.allocate
-local trace_registers = false trackers.register("structures.registers", function(v) trace_registers = v end)
+local trace_registers = false trackers.register("structures.registers", function(v) trace_registers = v end)
-local report_registers = logs.reporter("structure","registers")
+local report_registers = logs.reporter("structure","registers")
-local structures = structures
-local registers = structures.registers
-local helpers = structures.helpers
-local sections = structures.sections
-local documents = structures.documents
-local pages = structures.pages
-local references = structures.references
+local structures = structures
+local registers = structures.registers
+local helpers = structures.helpers
+local sections = structures.sections
+local documents = structures.documents
+local pages = structures.pages
+local references = structures.references
-local mappings = sorters.mappings
-local entries = sorters.entries
-local replacements = sorters.replacements
+local mappings = sorters.mappings
+local entries = sorters.entries
+local replacements = sorters.replacements
-local processors = typesetters.processors
-local splitprocessor = processors.split
+local processors = typesetters.processors
+local splitprocessor = processors.split
-local texgetcount = tex.getcount
+local variables = interfaces.variables
+local context = context
-local variables = interfaces.variables
-local context = context
-local commands = commands
-
-local matchingtilldepth = sections.matchingtilldepth
-local numberatdepth = sections.numberatdepth
-
-local absmaxlevel = 5 -- \c_strc_registers_maxlevel
+local matchingtilldepth, numberatdepth = sections.matchingtilldepth, sections.numberatdepth
-- some day we will share registers and lists (although there are some conceptual
-- differences in the application of keywords)
@@ -291,7 +286,7 @@ end
function registers.enhance(name,n)
local r = tobesaved[name].entries[n]
if r then
- r.references.realpage = texgetcount("realpageno")
+ r.references.realpage = texcount.realpageno
end
end
@@ -303,7 +298,7 @@ function registers.extend(name,tag,rawdata) -- maybe do lastsection internally
local r = tobesaved[name].entries[tag]
if r then
local rr = r.references
- rr.lastrealpage = texgetcount("realpageno")
+ rr.lastrealpage = texcount.realpageno
rr.lastsection = sections.currentid()
if rawdata then
if rawdata.entries then
@@ -668,31 +663,11 @@ function registers.flush(data,options,prefixspec,pagespec)
local collapse_singles = options.compress == variables.yes
local collapse_ranges = options.compress == variables.all
local result = data.result
- local maxlevel = 0
- --
- for i=1,#result do
- local data = result[i].data
- for d=1,#data do
- local m = #data[d].list
- if m > maxlevel then
- maxlevel = m
- end
- end
- end
- if maxlevel > absmaxlevel then
- maxlevel = absmaxlevel
- report_registers("limiting level to %a",maxlevel)
- end
- --
context.startregisteroutput()
-local done = { }
for i=1,#result do
-- ranges need checking !
local sublist = result[i]
- -- local done = { false, false, false, false }
-for i=1,maxlevel do
- done[i] = false
-end
+ local done = { false, false, false, false }
local data = sublist.data
local d, n = 0, 0
context.startregistersection(sublist.tag)
@@ -708,28 +683,20 @@ end
end
end
end
- -- ok, this is tricky: we use e[i] delayed so we need it to be local
- -- but we don't want to allocate too many entries so there we go
while d < #data do
d = d + 1
local entry = data[d]
- local e = { false, false, false }
-for i=3,maxlevel do
- e[i] = false
-end
+ local e = { false, false, false, false }
local metadata = entry.metadata
local kind = metadata.kind
local list = entry.list
- for i=1,maxlevel do
+ for i=1,4 do -- max 4
if list[i] then
e[i] = list[i][1]
end
if e[i] ~= done[i] then
if e[i] and e[i] ~= "" then
done[i] = e[i]
-for j=i+1,maxlevel do
- done[j] = false
-end
if n == i then
context.stopregisterentries()
context.startregisterentries(n)
@@ -746,8 +713,6 @@ end
local internal = entry.references.internal or 0
local seeparent = entry.references.seeparent or ""
local processor = entry.processors and entry.processors[1] or ""
- -- so, we need to keep e as is (local), or we need local title = e[i] ... which might be
- -- more of a problem
if metadata then
context.registerentry(processor,internal,seeparent,function() helpers.title(e[i],metadata) end)
else -- ?
@@ -755,9 +720,6 @@ end
end
else
done[i] = false
-for j=i+1,maxlevel do
- done[j] = false
-end
end
end
end
@@ -888,7 +850,6 @@ end
data.metadata.sorted = false
end
-
function registers.analyze(class,options)
context(registers.analyzed(class,options))
end