summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--luatexbase-attr.dtx18
-rw-r--r--luatexbase-cctb.dtx7
-rw-r--r--luatexbase-mcb.dtx23
3 files changed, 34 insertions, 14 deletions
diff --git a/luatexbase-attr.dtx b/luatexbase-attr.dtx
index 859803e..209ffd6 100644
--- a/luatexbase-attr.dtx
+++ b/luatexbase-attr.dtx
@@ -356,15 +356,23 @@ local texiowrite = texio.write
local whatsit_t = nodetype"whatsit"
local user_defined_t = nodesubtype"user_defined"
-luatexbase = luatexbase or { }
-local luatexbase = luatexbase
+luatexbase = luatexbase or { }
+local luatexbase = luatexbase
% \end{macrocode}
%
% This table holds the values of the allocated attributes, indexed by name.
%
% \begin{macrocode}
-attributes = {}
+luatexbase.attributes = luatexbase.attributes or { }
+local attributes = luatexbase.attributes
+% \end{macrocode}
+%
+% Scoping: we use locals for the attribute functions.
+%
+% \begin{macrocode}
+local new_attribute
+local unset_attribute
% \end{macrocode}
%
% In the \luatex ecosystem there are currently two functions that create a
@@ -396,7 +404,7 @@ end
%
% \begin{macrocode}
local last_alloc = 0
-local function new_attribute(name, silent)
+function new_attribute(name, silent)
if last_alloc >= 65535 then
if silent then
return -1
@@ -427,7 +435,7 @@ luatexbase.new_attribute = new_attribute
%
% \begin{macrocode}
local unset_value = (luatexbase.luatexversion < 37) and -1 or -2147483647
-local function unset_attribute(name)
+function unset_attribute(name)
tex.setattribute(attributes[name], unset_value)
end
luatexbase.unset_attribute = unset_attribute
diff --git a/luatexbase-cctb.dtx b/luatexbase-cctb.dtx
index 8958f20..1e95379 100644
--- a/luatexbase-cctb.dtx
+++ b/luatexbase-cctb.dtx
@@ -649,15 +649,16 @@ See the aforementioned source file(s) for copyright and licensing information.
%
% \begin{macrocode}
%<*luamodule>
-luatexbase = luatexbase or { }
-local luatexbase = { }
+luatexbase = luatexbase or { }
+local luatexbase = luatexbase
% \end{macrocode}
%
% The number associated to a CS name is remembered in the |catcodetables|
% table.
%
% \begin{macrocode}
-catcodetables = {}
+luatexbase.catcodetables = luatexbase.catcodetables or { }
+local catcodetables = luatexbase.catcodetables
local function catcodetabledef_from_tex(name, number)
catcodetables[name] = tonumber(number)
end
diff --git a/luatexbase-mcb.dtx b/luatexbase-mcb.dtx
index 9070c8f..0c04d4d 100644
--- a/luatexbase-mcb.dtx
+++ b/luatexbase-mcb.dtx
@@ -405,6 +405,17 @@ local err, warning, info, log = luatexbase.provides_module({
})
% \end{macrocode}
%
+% First we declare the function references for the entire scope.
+%
+% \begin{macrocode}
+local add_to_callback
+local call_callback
+local create_callback
+local priority_in_callback
+local remove_from_callback
+local reset_callback
+% \end{macrocode}
+%
% \subsubsection{Housekeeping}
%
% The main table: keys are callback names, and values are the associated
@@ -628,7 +639,7 @@ local handlers = {
% Add a function to a callback. First check arguments.
%
% \begin{macrocode}
-local function add_to_callback (name,func,description,priority)
+function add_to_callback (name,func,description,priority)
if type(func) ~= "function" then
return err("unable to add function:\nno proper function passed")
end
@@ -697,7 +708,7 @@ luatexbase.add_to_callback = add_to_callback
% Remove a function from a callback. First check arguments.
%
% \begin{macrocode}
-local function remove_from_callback (name, description)
+function remove_from_callback (name, description)
if not name or name == "" then
err("unable to remove function:\nno proper callback name passed")
return
@@ -751,7 +762,7 @@ luatexbase.remove_from_callback = remove_from_callback
% callback handler unless the callback is user-defined.
%
% \begin{macrocode}
-local function reset_callback (name, make_false)
+function reset_callback (name, make_false)
if not name or name == "" then
err("unable to reset:\nno proper callback name passed")
return
@@ -777,7 +788,7 @@ luatexbase.reset_callback = reset_callback
% not in the list.
%
% \begin{macrocode}
-local function priority_in_callback (name, description)
+function priority_in_callback (name, description)
if not name or name == ""
or not callbacktypes[name]
or not description then
@@ -809,7 +820,7 @@ luatexbase.priority_in_callback = priority_in_callback
% callback must also call it, see next function.
%
% \begin{macrocode}
-local function create_callback(name, ctype, default)
+function create_callback(name, ctype, default)
if not name then
err("unable to call callback:\nno proper name passed", name)
return nil
@@ -839,7 +850,7 @@ luatexbase.create_callback = create_callback
% the \texttt{create} function.
%
% \begin{macrocode}
-local function call_callback(name, ...)
+function call_callback(name, ...)
if not name then
err("unable to call callback:\nno proper name passed", name)
return nil