From f3178743528fed675598b87b938a61115fe90cd6 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 14 May 2010 18:30:43 +0000 Subject: luatextra update (13may10) git-svn-id: svn://tug.org/texlive/trunk@18252 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/luatex/luatextra/luaextra.lua | 601 --------------------- .../tex/luatex/luatextra/luamcallbacks.lua | 415 -------------- .../tex/luatex/luatextra/luatextra-latex.tex | 16 - .../texmf-dist/tex/luatex/luatextra/luatextra.lua | 319 +---------- .../texmf-dist/tex/luatex/luatextra/luatextra.sty | 227 ++------ 5 files changed, 54 insertions(+), 1524 deletions(-) delete mode 100644 Master/texmf-dist/tex/luatex/luatextra/luaextra.lua delete mode 100644 Master/texmf-dist/tex/luatex/luatextra/luamcallbacks.lua (limited to 'Master/texmf-dist/tex/luatex') diff --git a/Master/texmf-dist/tex/luatex/luatextra/luaextra.lua b/Master/texmf-dist/tex/luatex/luatextra/luaextra.lua deleted file mode 100644 index cbf1d426708..00000000000 --- a/Master/texmf-dist/tex/luatex/luatextra/luaextra.lua +++ /dev/null @@ -1,601 +0,0 @@ --- --- This is file `luaextra.lua', --- generated with the docstrip utility. --- --- The original source files were: --- --- luaextra.dtx (with options: `lua') --- This is a generated file. --- --- Copyright (C) 2009 by PRAGMA ADE / ConTeXt Development Team --- --- See ConTeXt's mreadme.pdf for the license. --- --- This work consists of the main source file luaextra.dtx --- and the derived file luaextra.lua. --- -do - local luatextra_module = { - name = "luaextra", - version = 0.91, - date = "2009/04/15", - description = "Lua additional functions.", - author = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux", - copyright = "PRAGMA ADE / ConTeXt Development Team", - license = "See ConTeXt's mreadme.pdf for the license", - } - - luatextra.provides_module(luatextra_module) -end - -function string:stripspaces() - return (self:gsub("^%s*(.-)%s*$", "%1")) -end - - -function string.is_boolean(str) - if type(str) == "string" then - if str == "true" or str == "yes" or str == "on" or str == "t" then - return true - elseif str == "false" or str == "no" or str == "off" or str == "f" then - return false - end - end - return nil -end - - -function string.is_number(str) - return str:find("^[%-%+]?[%d]-%.?[%d+]$") == 1 -end - - -lpeg.space = lpeg.S(" \t\f\v") -lpeg.newline = lpeg.P("\r\n") + lpeg.P("\r") +lpeg.P("\n") - - -if not table.fastcopy then do - - local type, pairs, getmetatable, setmetatable = - type, pairs, getmetatable, setmetatable - - local function fastcopy(old) -- fast one - if old then - local new = { } - for k,v in pairs(old) do - if type(v) == "table" then - new[k] = fastcopy(v) -- was just table.copy - else - new[k] = v - end - end - local mt = getmetatable(old) - if mt then - setmetatable(new,mt) - end - return new - else - return { } - end - end - - table.fastcopy = fastcopy - -end end - - -if not table.copy then do - - local type, pairs, getmetatable, setmetatable = type, pairs, getmetatable, setmetatable - - local function copy(t, tables) -- taken from lua wiki, slightly adapted - tables = tables or { } - local tcopy = {} - if not tables[t] then - tables[t] = tcopy - end - for i,v in pairs(t) do -- brrr, what happens with sparse indexed - if type(i) == "table" then - if tables[i] then - i = tables[i] - else - i = copy(i, tables) - end - end - if type(v) ~= "table" then - tcopy[i] = v - elseif tables[v] then - tcopy[i] = tables[v] - else - tcopy[i] = copy(v, tables) - end - end - local mt = getmetatable(t) - if mt then - setmetatable(tcopy,mt) - end - return tcopy - end - - table.copy = copy - -end end - - -function table.sortedkeys(tab) - local srt, kind = { }, 0 -- 0=unknown 1=string, 2=number 3=mixed - for key,_ in pairs(tab) do - srt[#srt+1] = key - if kind == 3 then - -- no further check - else - local tkey = type(key) - if tkey == "string" then - -- if kind == 2 then kind = 3 else kind = 1 end - kind = (kind == 2 and 3) or 1 - elseif tkey == "number" then - -- if kind == 1 then kind = 3 else kind = 2 end - kind = (kind == 1 and 3) or 2 - else - kind = 3 - end - end - end - if kind == 0 or kind == 3 then - table.sort(srt,function(a,b) return (tostring(a) < tostring(b)) end) - else - table.sort(srt) - end - return srt -end - -do - table.serialize_functions = true - table.serialize_compact = true - table.serialize_inline = true - - local function key(k) - if type(k) == "number" then -- or k:find("^%d+$") then - return "["..k.."]" - elseif noquotes and k:find("^%a[%a%d%_]*$") then - return k - else - return '["'..k..'"]' - end - end - - local function simple_table(t) - if #t > 0 then - local n = 0 - for _,v in pairs(t) do - n = n + 1 - end - if n == #t then - local tt = { } - for i=1,#t do - local v = t[i] - local tv = type(v) - if tv == "number" or tv == "boolean" then - tt[#tt+1] = tostring(v) - elseif tv == "string" then - tt[#tt+1] = ("%q"):format(v) - else - tt = nil - break - end - end - return tt - end - end - return nil - end - - local function serialize(root,name,handle,depth,level,reduce,noquotes,indexed) - handle = handle or print - reduce = reduce or false - if depth then - depth = depth .. " " - if indexed then - handle(("%s{"):format(depth)) - else - handle(("%s%s={"):format(depth,key(name))) - end - else - depth = "" - local tname = type(name) - if tname == "string" then - if name == "return" then - handle("return {") - else - handle(name .. "={") - end - elseif tname == "number" then - handle("[" .. name .. "]={") - elseif tname == "boolean" then - if name then - handle("return {") - else - handle("{") - end - else - handle("t={") - end - end - if root and next(root) then - local compact = table.serialize_compact - local inline = compact and table.serialize_inline - local first, last = nil, 0 -- #root cannot be trusted here - if compact then - for k,v in ipairs(root) do -- NOT: for k=1,#root do (why) - if not first then first = k end - last = last + 1 - end - end - for _,k in pairs(table.sortedkeys(root)) do - local v = root[k] - local t = type(v) - if compact and first and type(k) == "number" and k >= first and k <= last then - if t == "number" then - handle(("%s %s,"):format(depth,v)) - elseif t == "string" then - if reduce and (v:find("^[%-%+]?[%d]-%.?[%d+]$") == 1) then - handle(("%s %s,"):format(depth,v)) - else - handle(("%s %q,"):format(depth,v)) - end - elseif t == "table" then - if not next(v) then - handle(("%s {},"):format(depth)) - elseif inline then - local st = simple_table(v) - if st then - handle(("%s { %s },"):format(depth,table.concat(st,", "))) - else - serialize(v,k,handle,depth,level+1,reduce,noquotes,true) - end - else - serialize(v,k,handle,depth,level+1,reduce,noquotes,true) - end - elseif t == "boolean" then - handle(("%s %s,"):format(depth,tostring(v))) - elseif t == "function" then - if table.serialize_functions then - handle(('%s loadstring(%q),'):format(depth,string.dump(v))) - else - handle(('%s "function",'):format(depth)) - end - else - handle(("%s %q,"):format(depth,tostring(v))) - end - elseif k == "__p__" then -- parent - if false then - handle(("%s __p__=nil,"):format(depth)) - end - elseif t == "number" then - handle(("%s %s=%s,"):format(depth,key(k),v)) - elseif t == "string" then - if reduce and (v:find("^[%-%+]?[%d]-%.?[%d+]$") == 1) then - handle(("%s %s=%s,"):format(depth,key(k),v)) - else - handle(("%s %s=%q,"):format(depth,key(k),v)) - end - elseif t == "table" then - if not next(v) then - handle(("%s %s={},"):format(depth,key(k))) - elseif inline then - local st = simple_table(v) - if st then - handle(("%s %s={ %s },"):format(depth,key(k),table.concat(st,", "))) - else - serialize(v,k,handle,depth,level+1,reduce,noquotes) - end - else - serialize(v,k,handle,depth,level+1,reduce,noquotes) - end - elseif t == "boolean" then - handle(("%s %s=%s,"):format(depth,key(k),tostring(v))) - elseif t == "function" then - if table.serialize_functions then - handle(('%s %s=loadstring(%q),'):format(depth,key(k),string.dump(v))) - else - handle(('%s %s="function",'):format(depth,key(k))) - end - else - handle(("%s %s=%q,"):format(depth,key(k),tostring(v))) - -- handle(('%s %s=loadstring(%q),'):format(depth,key(k),string.dump(function() return v end))) - end - end - if level > 0 then - handle(("%s},"):format(depth)) - else - handle(("%s}"):format(depth)) - end - else - handle(("%s}"):format(depth)) - end - end - - function table.serialize(root,name,reduce,noquotes) - local t = { } - local function flush(s) - t[#t+1] = s - end - serialize(root, name, flush, nil, 0, reduce, noquotes) - return table.concat(t,"\n") - end - - function table.tostring(t, name) - return table.serialize(t, name) - end - - function table.tohandle(handle,root,name,reduce,noquotes) - serialize(root, name, handle, nil, 0, reduce, noquotes) - end - - -- sometimes tables are real use (zapfino extra pro is some 85M) in which - -- case a stepwise serialization is nice; actually, we could consider: - -- - -- for line in table.serializer(root,name,reduce,noquotes) do - -- ...(line) - -- end - -- - -- so this is on the todo list - - table.tofile_maxtab = 2*1024 - - function table.tofile(filename,root,name,reduce,noquotes) - local f = io.open(filename,'w') - if f then - local concat = table.concat - local maxtab = table.tofile_maxtab - if maxtab > 1 then - local t = { } - local function flush(s) - t[#t+1] = s - if #t > maxtab then - f:write(concat(t,"\n"),"\n") -- hm, write(sometable) should be nice - t = { } - end - end - serialize(root, name, flush, nil, 0, reduce, noquotes) - f:write(concat(t,"\n"),"\n") - else - local function flush(s) - f:write(s,"\n") - end - serialize(root, name, flush, nil, 0, reduce, noquotes) - end - f:close() - end - end - -end - - -function table.tohash(t) - local h = { } - for _, v in pairs(t) do -- no ipairs here - h[v] = true - end - return h -end - - -function table.fromhash(t) - local h = { } - for k, v in pairs(t) do -- no ipairs here - if v then h[#h+1] = k end - end - return h -end - - -function table.contains_value(t, val) - if t then - for k, v in pairs(t) do - if v==val then - return true - end - end - end - return false -end - - -function table.contains_key(t, key) - if t then - for k, v in pairs(t) do - if k==key then - return true - end - end - end - return false -end - - -function table.value_position(t, val) - if t then - local i=1 - for k, v in pairs(t) do - if v==val then - return i - end - i=i+1 - end - end - return 0 -end - - -function table.key_position(t, key) - if t then - local i=1 - for k,v in pairs(t) do - if k==key then - return i - end - i = i+1 - end - end - return -1 -end - - -function table.remove_value(t, v) - local p = table.value_position(t,v) - if p ~= -1 then - table.remove(t, table.value_position(t,v)) - end -end - - -function table.remove_key(t, k) - local p = table.key_position(t,k) - if p ~= -1 then - table.remove(t, table.key_position(t,k)) - end -end - - -function table.is_empty(t) - return not t or not next(t) -end - - -fpath = { } - - -function fpath.removesuffix(filename) - return filename:gsub("%.[%a%d]+$", "") -end - - -function fpath.addsuffix(filename, suffix) - if not filename:find("%.[%a%d]+$") then - return filename .. "." .. suffix - else - return filename - end -end - - -function fpath.replacesuffix(filename, suffix) - if not filename:find("%.[%a%d]+$") then - return filename .. "." .. suffix - else - return (filename:gsub("%.[%a%d]+$","."..suffix)) - end -end - - -function fpath.dirname(name) - return name:match("^(.+)[/\\].-$") or "" -end - - -function fpath.basename(fname) - if not fname then - return nil - end - return fname:match("^.+[/\\](.-)$") or fname -end - - -function fpath.nameonly(name) - return ((name:match("^.+[/\\](.-)$") or name):gsub("%..*$","")) -end - - -function fpath.suffix(name) - return name:match("^.+%.([^/\\]-)$") or "" -end - - -function fpath.join(...) - local pth = table.concat({...},"/") - pth = pth:gsub("\\","/") - local a, b = pth:match("^(.*://)(.*)$") - if a and b then - return a .. b:gsub("//+","/") - end - a, b = pth:match("^(//)(.*)$") - if a and b then - return a .. b:gsub("//+","/") - end - return (pth:gsub("//+","/")) -end - - -function fpath.split(str) - local t = { } - str = str:gsub("\\", "/") - str = str:gsub("(%a):([;/])", "%1\001%2") - for name in str:gmatch("([^;:]+)") do - if name ~= "" then - name = name:gsub("\001",":") - t[#t+1] = name - end - end - return t -end - - -function fpath.normalize_sep(str) - return str:gsub("\\", "/") -end - - -function fpath.localize_sep(str) - if os.type == 'windows' or type == 'msdos' then - return str:gsub("/", "\\") - else - return str:gsub("\\", "/") - end -end - - -function lfs.is_writable(name) - local f = io.open(name, 'w') - if f then - f:close() - return true - else - return false - end -end - - -function lfs.is_readable(name) - local f = io.open(name,'r') - if f then - f:close() - return true - else - return false - end -end - - -if not math.round then - function math.round(x) - return math.floor(x + 0.5) - end -end - - -if not math.div then - function math.div(n,m) - return floor(n/m) - end -end - - -if not math.mod then - function math.mod(n,m) - return n % m - end -end - --- --- End of File `luaextra.lua'. diff --git a/Master/texmf-dist/tex/luatex/luatextra/luamcallbacks.lua b/Master/texmf-dist/tex/luatex/luatextra/luamcallbacks.lua deleted file mode 100644 index 77dc49c7681..00000000000 --- a/Master/texmf-dist/tex/luatex/luatextra/luamcallbacks.lua +++ /dev/null @@ -1,415 +0,0 @@ --- --- This is file `luamcallbacks.lua', --- generated with the docstrip utility. --- --- The original source files were: --- --- luamcallbacks.dtx (with options: `lua') --- This is a generated file. --- --- Copyright (C) 2009 by Elie Roux --- --- This work is under the CC0 license. --- --- This work consists of the main source file luamcallbacks.dtx --- and the derived files --- luamcallbacks.lua, luamcallbacks-test.tex, luamcallbacks.pdf. --- - -luamcallbacks = { } - -luamcallbacks.module = { - name = "luamcallbacks", - version = 0.93, - date = "2009/09/18", - description = "Module to register several functions in a callback.", - author = "Hans Hagen & Elie Roux", - copyright = "Hans Hagen & Elie Roux", - license = "CC0", -} - -luatextra.provides_module(luamcallbacks.module) - - -luamcallbacks.callbacklist = luamcallbacks.callbacklist or { } - - -luamcallbacks.lua_callbacks_defaults = { } - -local format = string.format - - -local list = 1 -local data = 2 -local first = 3 -local simple = 4 - - -luamcallbacks.callbacktypes = luamcallbacks.callbacktypes or { -buildpage_filter = simple, -token_filter = first, -pre_output_filter = list, -hpack_filter = list, -process_input_buffer = data, -mlist_to_hlist = list, -vpack_filter = list, -define_font = first, -open_read_file = first, -linebreak_filter = list, -post_linebreak_filter = list, -pre_linebreak_filter = list, -start_page_number = simple, -stop_page_number = simple, -start_run = simple, -show_error_hook = simple, -stop_run = simple, -hyphenate = simple, -ligaturing = simple, -kerning = data, -find_write_file = first, -find_read_file = first, -find_vf_file = data, -find_map_file = data, -find_format_file = data, -find_opentype_file = data, -find_output_file = data, -find_truetype_file = data, -find_type1_file = data, -find_data_file = data, -find_pk_file = data, -find_font_file = data, -find_image_file = data, -find_ocp_file = data, -find_sfd_file = data, -find_enc_file = data, -read_sfd_file = first, -read_map_file = first, -read_pk_file = first, -read_enc_file = first, -read_vf_file = first, -read_ocp_file = first, -read_opentype_file = first, -read_truetype_file = first, -read_font_file = first, -read_type1_file = first, -read_data_file = first, -} - - -if tex.luatexversion > 42 then - luamcallbacks.callbacktypes["process_output_buffer"] = data -end - - -luamcallbacks.internalregister = luamcallbacks.internalregister or callback.register - -local callbacktypes = luamcallbacks.callbacktypes - -luamcallbacks.log = luamcallbacks.log or function(...) - luatextra.module_log('luamcallbacks', format(...)) -end - -luamcallbacks.info = luamcallbacks.info or function(...) - luatextra.module_info('luamcallbacks', format(...)) -end - -luamcallbacks.warning = luamcallbacks.warning or function(...) - luatextra.module_warning('luamcallbacks', format(...)) -end - -luamcallbacks.error = luamcallbacks.error or function(...) - luatextra.module_error('luamcallbacks', format(...)) -end - - -function luamcallbacks.str_to_type(str) - if str == 'list' then - return list - elseif str == 'data' then - return data - elseif str == 'first' then - return first - elseif str == 'simple' then - return simple - else - return nil - end -end - - -function luamcallbacks.create(name, ctype, default) - if not name then - luamcallbacks.error(format("unable to call callback, no proper name passed", name)) - return nil - end - if not ctype or not default then - luamcallbacks.error(format("unable to create callback '%s', callbacktype or default function not specified", name)) - return nil - end - if callbacktypes[name] then - luamcallbacks.error(format("unable to create callback '%s', callback already exists", name)) - return nil - end - local temp = luamcallbacks.str_to_type(ctype) - if not temp then - luamcallbacks.error(format("unable to create callback '%s', type '%s' undefined", name, ctype)) - return nil - end - ctype = temp - luamcallbacks.lua_callbacks_defaults[name] = default - callbacktypes[name] = ctype -end - - -function luamcallbacks.call(name, ...) - if not name then - luamcallbacks.error(format("unable to call callback, no proper name passed", name)) - return nil - end - if not luamcallbacks.lua_callbacks_defaults[name] then - luamcallbacks.error(format("unable to call lua callback '%s', unknown callback", name)) - return nil - end - local l = luamcallbacks.callbacklist[name] - local f - if not l then - f = luamcallbacks.lua_callbacks_defaults[name] - else - if callbacktypes[name] == list then - f = luamcallbacks.listhandler(name) - elseif callbacktypes[name] == data then - f = luamcallbacks.datahandler(name) - elseif callbacktypes[name] == simple then - f = luamcallbacks.simplehandler(name) - elseif callbacktypes[name] == first then - f = luamcallbacks.firsthandler(name) - else - luamcallbacks.error("unknown callback type") - end - end - return f(...) -end - - -function luamcallbacks.add (name,func,description,priority) - if type(func) ~= "function" then - luamcallbacks.error("unable to add function, no proper function passed") - return - end - if not name or name == "" then - luamcallbacks.error("unable to add function, no proper callback name passed") - return - elseif not callbacktypes[name] then - luamcallbacks.error( - format("unable to add function, '%s' is not a valid callback", - name)) - return - end - if not description or description == "" then - luamcallbacks.error( - format("unable to add function to '%s', no proper description passed", - name)) - return - end - if luamcallbacks.get_priority(name, description) ~= 0 then - luamcallbacks.warning( - format("function '%s' already registered in callback '%s'", - description, name)) - end - local l = luamcallbacks.callbacklist[name] - if not l then - l = {} - luamcallbacks.callbacklist[name] = l - if not luamcallbacks.lua_callbacks_defaults[name] then - if callbacktypes[name] == list then - luamcallbacks.internalregister(name, luamcallbacks.listhandler(name)) - elseif callbacktypes[name] == data then - luamcallbacks.internalregister(name, luamcallbacks.datahandler(name)) - elseif callbacktypes[name] == simple then - luamcallbacks.internalregister(name, luamcallbacks.simplehandler(name)) - elseif callbacktypes[name] == first then - luamcallbacks.internalregister(name, luamcallbacks.firsthandler(name)) - else - luamcallbacks.error("unknown callback type") - end - end - end - local f = { - func = func, - description = description, - } - priority = tonumber(priority) - if not priority or priority > #l then - priority = #l+1 - elseif priority < 1 then - priority = 1 - end - if callbacktypes[name] == first and (priority ~= 1 or #l ~= 0) then - luamcallbacks.warning(format("several callbacks registered in callback '%s', only the first function will be active.", name)) - end - table.insert(l,priority,f) - luamcallbacks.log( - format("inserting function '%s' at position %s in callback list for '%s'", - description,priority,name)) -end - - -function luamcallbacks.get_priority (name, description) - if not name or name == "" or not callbacktypes[name] or not description then - return 0 - end - local l = luamcallbacks.callbacklist[name] - if not l then return 0 end - for p, f in pairs(l) do - if f.description == description then - return p - end - end - return 0 -end - - -function luamcallbacks.remove (name, description) - if not name or name == "" then - luamcallbacks.error("unable to remove function, no proper callback name passed") - return - elseif not callbacktypes[name] then - luamcallbacks.error( - format("unable to remove function, '%s' is not a valid callback", - name)) - return - end - if not description or description == "" then - luamcallbacks.error( - format("unable to remove function from '%s', no proper description passed", - name)) - return - end - local l = luamcallbacks.callbacklist[name] - if not l then - luamcallbacks.error(format("no callback list for '%s'",name)) - return - end - for k,v in ipairs(l) do - if v.description == description then - table.remove(l,k) - luamcallbacks.log( - format("removing function '%s' from '%s'",description,name)) - if not next(l) then - luamcallbacks.callbacklist[name] = nil - if not luamcallbacks.lua_callbacks_defaults[name] then - luamcallbacks.internalregister(name, nil) - end - end - return - end - end - luamcallbacks.warning( - format("unable to remove function '%s' from '%s'",description,name)) -end - - -function luamcallbacks.reset (name) - if not name or name == "" then - luamcallbacks.error("unable to reset, no proper callback name passed") - return - elseif not callbacktypes[name] then - luamcallbacks.error( - format("reset error, '%s' is not a valid callback", - name)) - return - end - if not luamcallbacks.lua_callbacks_defaults[name] then - luamcallbacks.internalregister(name, nil) - end - local l = luamcallbacks.callbacklist[name] - if l then - luamcallbacks.log(format("resetting callback list '%s'",name)) - luamcallbacks.callbacklist[name] = nil - end -end - - -function luamcallbacks.listhandler (name) - return function(head,...) - local l = luamcallbacks.callbacklist[name] - if l then - local done = true - for _, f in ipairs(l) do - -- the returned value can be either true or a new head plus true - rtv1, rtv2 = f.func(head,...) - if type(rtv1) == 'boolean' then - done = rtv1 - elseif type (rtv1) == 'userdata' then - head = rtv1 - end - if type(rtv2) == 'boolean' then - done = rtv2 - elseif type(rtv2) == 'userdata' then - head = rtv2 - end - if done == false then - luamcallbacks.error(format( - "function \"%s\" returned false in callback '%s'", - f.description, name)) - end - end - return head, done - else - return head, false - end - end -end - - -function luamcallbacks.datahandler (name) - return function(data,...) - local l = luamcallbacks.callbacklist[name] - if l then - for _, f in ipairs(l) do - data = f.func(data,...) - end - end - return data - end -end - - -function luamcallbacks.firsthandler (name) - return function(...) - local l = luamcallbacks.callbacklist[name] - if l then - local f = l[1].func - return f(...) - else - return nil, false - end - end -end - - -function luamcallbacks.simplehandler (name) - return function(...) - local l = luamcallbacks.callbacklist[name] - if l then - for _, f in ipairs(l) do - f.func(...) - end - end - end -end - - -callback.add = luamcallbacks.add -callback.remove = luamcallbacks.remove -callback.reset = luamcallbacks.reset -callback.create = luamcallbacks.create -callback.call = luamcallbacks.call -callback.get_priority = luamcallbacks.get_priority - -callback.register = function (...) -luamcallbacks.error("function callback.register has been deleted by luamcallbacks, please use callback.add instead.") -end - --- --- End of File `luamcallbacks.lua'. diff --git a/Master/texmf-dist/tex/luatex/luatextra/luatextra-latex.tex b/Master/texmf-dist/tex/luatex/luatextra/luatextra-latex.tex index 024b1888307..dc9a1fff5f3 100644 --- a/Master/texmf-dist/tex/luatex/luatextra/luatextra-latex.tex +++ b/Master/texmf-dist/tex/luatex/luatextra/luatextra-latex.tex @@ -15,22 +15,6 @@ %% and the derived files %% luatextra.sty, luatextra.lua, luatextra-latex.tex, luatextra.pdf %% -\def\ltxtra@temp#1{% -\ifnum\count27#1=32768 % - \count27#1=65536 % -\fi -}% -\ltxtra@temp0% -\ltxtra@temp1% -\ltxtra@temp2% -\ltxtra@temp3% -\ltxtra@temp4% -\ltxtra@temp5% -\ltxtra@temp6% -\let\newcount\globcount -\let\newdimen\globdimen -\let\newskip\globskip -\let\newbox\globbox \endinput %% %% End of file `luatextra-latex.tex'. diff --git a/Master/texmf-dist/tex/luatex/luatextra/luatextra.lua b/Master/texmf-dist/tex/luatex/luatextra/luatextra.lua index 2340fec3164..17f1345624d 100644 --- a/Master/texmf-dist/tex/luatex/luatextra/luatextra.lua +++ b/Master/texmf-dist/tex/luatex/luatextra/luatextra.lua @@ -15,280 +15,24 @@ -- and the derived files -- luatextra.sty, luatextra.lua, luatextra-latex.tex, luatextra.pdf -- -do - local luatextrapath = kpse.find_file("luatextra.lua") - if luatextrapath then - if luatextrapath:sub(1,2) == "./" then - luatextrapath = luatextrapath:sub(3) - end - texio.write_nl('('..luatextrapath) - end -end - - -luatextra = {} - module("luatextra", package.seeall) - - -luatextra.modules = {} - -luatextra.modules['luatextra'] = { - version = 0.95, +luatexbase.provides_module { + version = 0.97, name = "luatextra", - date = "2009/12/16", + date = "2010/05/10", description = "Additional low level functions for LuaTeX", - author = "Elie Roux", - copyright = "Elie Roux, 2009", + author = "Elie Roux and Manuel Pegourie-Gonnard", + copyright = "Elie Roux, 2009 and Manuel Pegourie-Gonnard, 2010", license = "CC0", } - local format = string.format - - -luatextra.internal_warning_spaces = " " - -function luatextra.internal_warning(msg) - if not msg then return end - texio.write_nl(format("\nLuaTeXtra Warning: %s\n\n", msg)) -end - -luatextra.internal_error_spaces = " " - -function luatextra.internal_error(msg) - if not msg then return end - tex.sprint(format("\\immediate\\write16{}\\errmessage{LuaTeXtra error: %s^^J^^J}", msg)) -end - - -function luatextra.module_error(package, msg, helpmsg) - if not package or not msg then - return - end - if helpmsg then - tex.sprint(format("\\errhelp{%s}", helpmsg)) - end - tex.sprint(format("\\luatexModuleError{%s}{%s}", package, msg)) -end - -function luatextra.module_warning(modulename, msg) - if not modulename or not msg then - return - end - texio.write_nl(format("\nModule %s Warning: %s\n\n", modulename, msg)) -end - -function luatextra.module_log(modulename, msg) - if not modulename or not msg then - return - end - texio.write_nl('log', format("%s: %s", modulename, msg)) -end - -function luatextra.module_term(modulename, msg) - if not modulename or not msg then - return - end - texio.write_nl('term', format("%s: %s", modulename, msg)) -end - -function luatextra.module_info(modulename, msg) - if not modulename or not msg then - return - end - texio.write_nl(format("%s: %s\n", modulename, msg)) -end - - -function luatextra.find_module_file(name) - if string.sub(name, -4) ~= '.lua' then - name = name..'.lua' - end - path = kpse.find_file(name, 'tex') - if not path then - path = kpse.find_file(name, 'texmfscripts') - end - return path, name -end - - -luatextra.module = module - - -function luatextra.use_module(name) - if not name or luatextra.modules[name] then - return - end - local path, filename = luatextra.find_module_file(name) - if not path then - luatextra.internal_error(format("unable to find lua module %s", name)) - else - if path:sub(1,2) == "./" then - path = path:sub(3) - end - texio.write_nl('('..path) - dofile(path) - if not luatextra.modules[name] then - luatextra.internal_warning(format("You have requested module `%s',\n%s but the file %s does not provide it.", name, luatextra.internal_warning_spaces, filename)) - end - if not package.loaded[name] then - luatextra.module(name, package.seeall) - end - texio.write(')') - end -end - - -function luatextra.datetonumber(date) - numbers = string.gsub(date, "(%d+)/(%d+)/(%d+)", "%1%2%3") - return tonumber(numbers) -end - -function luatextra.isdate(date) - for _, _ in string.gmatch(date, "%d+/%d+/%d+") do - return true - end - return false -end - -local date, number = 1, 2 - -function luatextra.versiontonumber(version) - if luatextra.isdate(version) then - return {type = date, version = luatextra.datetonumber(version), orig = version} - else - return {type = number, version = tonumber(version), orig = version} - end -end - -luatextra.requiredversions = {} - - -function luatextra.require_module(name, version) - if not name then - return - end - if not version then - return luatextra.use_module(name) - end - luaversion = luatextra.versiontonumber(version) - if luatextra.modules[name] then - if luaversion.type == date then - if luatextra.datetonumber(luatextra.modules[name].date) < luaversion.version then - luatextra.internal_error(format("found module `%s' loaded in version %s, but version %s was required", name, luatextra.modules[name].date, version)) - end - else - if luatextra.modules[name].version < luaversion.version then - luatextra.internal_error(format("found module `%s' loaded in version %.02f, but version %s was required", name, luatextra.modules[name].version, version)) - end - end - else - luatextra.requiredversions[name] = luaversion - luatextra.use_module(name) - end -end - - -function luatextra.provides_module(mod) - if not mod then - luatextra.internal_error('cannot provide nil module') - return - end - if not mod.version or not mod.name or not mod.date or not mod.description then - luatextra.internal_error('invalid module registered, fields name, version, date and description are mandatory') - return - end - requiredversion = luatextra.requiredversions[mod.name] - if requiredversion then - if requiredversion.type == date and requiredversion.version > luatextra.datetonumber(mod.date) then - luatextra.internal_error(format("loading module %s in version %s, but version %s was required", mod.name, mod.date, requiredversion.orig)) - elseif requiredversion.type == number and requiredversion.version > mod.version then - luatextra.internal_error(format("loading module %s in version %.02f, but version %s was required", mod.name, mod.version, requiredversion.orig)) - end - end - luatextra.modules[mod.name] = module - texio.write_nl('log', format("Lua module: %s %s v%.02f %s\n", mod.name, mod.date, mod.version, mod.description)) -end - - -luatextra.use_module('luaextra') - - -function luatextra.kpse_module_loader(mod) - local file = luatextra.find_module_file(mod) - if file then - local loader, error = loadfile(file) - if loader then - texio.write_nl("(" .. file .. ")") - return loader - end - return "\n\t[luatextra.kpse_module_loader] Loading error:\n\t" - .. error - end - return "\n\t[luatextra.kpse_module_loader] Search failed" -end - -table.insert(package.loaders, luatextra.kpse_module_loader) - - -luatextra.attributes = {} - -tex.attributenumber = luatextra.attributes - -function luatextra.attributedef_from_tex(name, number) - truename = name:gsub('[\\ ]', '') - luatextra.attributes[truename] = tonumber(number) -end - - -luatextra.catcodetables = {} - -tex.catcodetablenumber = luatextra.catcodetables - -function luatextra.catcodetabledef_from_tex(name, number) - truename = name:gsub('[\\ ]', '') - luatextra.catcodetables[truename] = tonumber(number) -end - - -function luatextra.catcodetable_do_shortcuts() - local cat = tex.catcodetablenumber - local val = cat['CatcodeTableLaTeX'] - if val then - cat['latex'] = val - end - val = cat['CatcodeTableLaTeXAtLetter'] - if val then - cat['latex-package'] = val - cat['latex-atletter'] = val - end - val = cat['CatcodeTableIniTeX'] - if val then - cat['ini'] = val - end - val = cat['CatcodeTableExpl'] - if val then - cat['expl3'] = val - cat['expl'] = val - end - val = cat['CatcodeTableString'] - if val then - cat['string'] = val - end - val = cat['CatcodeTableOther'] - if val then - cat['other'] = val - end -end - - function luatextra.open_read_file(filename) local path = kpse.find_file(filename) local env = { ['filename'] = filename, ['path'] = path, } - luamcallbacks.call('pre_read_file', env) + luatexbase.call_callback('pre_read_file', env) path = env.path if not path then return @@ -305,39 +49,29 @@ function luatextra.open_read_file(filename) env.close = luatextra.close return env end - - function luatextra.reader(env) local line = (env.file):read() - line = luamcallbacks.call('file_reader', env, line) + line = luatexbase.call_callback('file_reader', env, line) return line end - function luatextra.close(env) (env.file):close() - luamcallbacks.call('file_close', env) + luatexbase.call_callback('file_close', env) end - - function luatextra.default_reader(env, line) return line end - function luatextra.default_close(env) return end - function luatextra.default_pre_read(env) return env end - - do if tex.luatexversion < 36 then fontloader = fontforge end end - function luatextra.find_font(name) local types = {'ofm', 'ovf', 'opentype fonts', 'truetype fonts'} local path = kpse.find_file(name) @@ -348,15 +82,12 @@ function luatextra.find_font(name) end return nil end - function luatextra.font_load_error(error) luatextra.module_warning('luatextra', string.format('%s\nloading lmr10 instead...', error)) end - function luatextra.load_default_font(size) return font.read_tfm("lmr10", size) end - function luatextra.define_font(name, size) if (size < 0) then size = (- 655.36) * size end local fontinfos = { @@ -385,7 +116,7 @@ function luatextra.define_font(name, size) elseif ext == 'vf' or ext == 'ovf' then f = font.read_vf(name, size) elseif ext == 'ttf' or ext == 'otf' or ext == 'ttc' then - f = callback.call('open_otf_font', fontinfos) + f = luatexbase.call_callback('open_otf_font', fontinfos) else luatextra.font_load_error("unable to determine the type of font "..name) f = luatextra.load_default_font(size) @@ -394,39 +125,27 @@ function luatextra.define_font(name, size) luatextra.font_load_error("unable to load font "..name) f = luatextra.load_default_font(size) end - callback.call('post_font_opening', f, fontinfos) + luatexbase.call_callback('post_font_opening', f, fontinfos) return f end - function luatextra.default_font_syntax(fontinfos) return end - function luatextra.default_open_otf(fontinfos) return nil end - function luatextra.default_post_font(f, fontinfos) return true end - function luatextra.register_font_callback() - callback.add('define_font', luatextra.define_font, 'luatextra.define_font') -end - -do - luatextra.use_module('luamcallbacks') - callback.create('pre_read_file', 'simple', luatextra.default_pre_read) - callback.create('file_reader', 'data', luatextra.default_reader) - callback.create('file_close', 'simple', luatextra.default_close) - callback.add('open_read_file', luatextra.open_read_file, 'luatextra.open_read_file') - callback.create('font_syntax', 'simple', luatextra.default_font_syntax) - callback.create('open_otf_font', 'first', luatextra.default_open_otf) - callback.create('post_font_opening', 'simple', luatextra.default_post_font) - - if luatextrapath then - texio.write(')') - end -end + luatexbase.add_to_callback('define_font', luatextra.define_font, 'luatextra.define_font') +end + luatexbase.create_callback('pre_read_file', 'simple', luatextra.default_pre_read) + luatexbase.create_callback('file_reader', 'data', luatextra.default_reader) + luatexbase.create_callback('file_close', 'simple', luatextra.default_close) + luatexbase.add_to_callback('open_read_file', luatextra.open_read_file, 'luatextra.open_read_file') + luatexbase.create_callback('font_syntax', 'simple', luatextra.default_font_syntax) + luatexbase.create_callback('open_otf_font', 'first', luatextra.default_open_otf) + luatexbase.create_callback('post_font_opening', 'simple', luatextra.default_post_font) -- -- End of File `luatextra.lua'. diff --git a/Master/texmf-dist/tex/luatex/luatextra/luatextra.sty b/Master/texmf-dist/tex/luatex/luatextra/luatextra.sty index 090e821a509..ced176ec071 100644 --- a/Master/texmf-dist/tex/luatex/luatextra/luatextra.sty +++ b/Master/texmf-dist/tex/luatex/luatextra/luatextra.sty @@ -27,35 +27,51 @@ \RequirePackage{ifluatex} \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luatextra} - [2009/12/16 v0.95 LuaTeX extra low-level macros] - \RequirePackage{etex}[1998/03/26] + [2010/05/10 v0.97 LuaTeX extra low-level macros] \fi \def\LuaTeX{Lua\TeX } \def\LuaLaTeX{Lua\LaTeX } - +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname RequirePackage\endcsname\relax + \input ifluatex.sty +\else + \RequirePackage{ifluatex} +\fi \ifluatex\else - \expandafter\ifx\csname ProvidesPackage\endcsname\relax - \immediate\write16{} - \immediate\write16{Package luatextra Warning: this package should be used with LuaTeX.} - \else - \PackageWarning{luatextra}{this package should be used with LuaTeX.} - \fi + \begingroup + \expandafter\ifx\csname PackageWarningNoLine\endcsname\relax + \def\x#1#2{\begingroup\newlinechar10 + \immediate\write16{Package #1 warning: #2}\endgroup} + \else + \let\x\PackageWarningNoLine + \fi + \expandafter\endgroup + \x{luatexbase-modutils}{LuaTeX is required for this package.^^J + Aborting package loading.} \expandafter\endinput \fi - -\expandafter\ifx\csname ProvidesPackage\endcsname\relax - \def\luatexRequireModule#1#2{\luadirect{luatextra.require_module([[#1]], [[#2]])}} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname RequirePackage\endcsname\relax + \input luatexbase-modutils.sty + \input luatexbase-attr.sty + \input luatexbase-cctb.sty + \input luatexbase-regs.sty + \input luatexbase-mcb.sty \else + \RequirePackage{luatexbase-modutils} + \RequirePackage{luatexbase-attr} + \RequirePackage{luatexbase-cctb} + \RequirePackage{luatexbase-regs} + \RequirePackage{luatexbase-mcb} +\fi +\luatexUseModule{lualibs} +\expandafter\ifx\csname RequirePackage\endcsname\relax \else \RequirePackage{environ} - \NewEnviron{luacode}{\luadirect{\BODY}} - \newcommand\luatexRequireModule[2][0]{\luadirect{luatextra.require_module([[#2]], [[#1]])}} - \input luatextra-latex.tex + \NewEnviron{luacode}{\directlua{\BODY}} \fi - - \ifnum\luatexversion<36 \def\directlua{\pdfprimitive\directlua0} \def\latelua{\pdfprimitive\latelua0} @@ -87,180 +103,10 @@ \let\saveluatexcatcodetable\luatexsavecatcodetable \let\luaclose\luatexcloselua \fi - - -\luadirect{dofile(kpse.find_file("luatextra.lua"))} - - +\directlua{dofile(kpse.find_file("luatextra.lua"))} \def\ltxtra@RegisterFontCallback{ - \luadirect{luatextra.register_font_callback()} + \directlua{luatextra.register_font_callback()} } - - -\def\luatexModuleError#1#2{% - \errorcontextlines=0\relax - \immediate\write16{}% - \errmessage{Module #1 error: #2^^J^^J% -See the module #1 documentation for explanation.^^J ...^^J}% -} - -\def\luatexUseModule#1{\luadirect{luatextra.use_module([[#1]])}} - - -\newcount\luatexattdefcounter -\luatexattdefcounter = 1 - -\def\newluatexattribute#1{% - \ifnum\luatexattdefcounter<65535\relax % - \global\advance\luatexattdefcounter by 1\relax % - \allocationnumber\luatexattdefcounter % - \ifluatex % - \global\luatexattributedef#1=\allocationnumber % - \fi % - \wlog{\string#1=\string\luatexattribute\the\allocationnumber}% - \luadirect{% - luatextra.attributedef_from_tex([[\noexpand#1]], '\number\allocationnumber')}% - \else % - \errmessage{No room for a new \string\attribute}% - \fi % -} - - -\def\setluatexattribute#1#2{% - #1=\numexpr#2\relax % -} - -\def\unsetluatexattribute#1{% - \ifnum\luatexversion<37\relax % - #1=-1\relax % - \else % - #1=-"7FFFFFFF\relax % - \fi % -} - - -\newcount\luatexcatcodetabledefcounter - -\luatexcatcodetabledefcounter = 1 - -\def\newluatexcatcodetable#1{% - \ifnum\luatexcatcodetabledefcounter<1114110\relax % 0x10FFFF is maximal \chardef - \global\advance\luatexcatcodetabledefcounter by 1\relax % - \allocationnumber=\luatexcatcodetabledefcounter % - \global\chardef#1=\allocationnumber % - \luadirect{% - luatextra.catcodetabledef_from_tex([[\noexpand#1]], '\number\allocationnumber')}% - \wlog{\string#1=\string\catcodetable\the\allocationnumber}% - \else % - \errmessage{No room for a new \string\catcodetable}% - \fi % -} - - -\expandafter\edef\csname ltxtra@AtEnd\endcsname{% - \catcode64 \the\catcode64\relax -} - -\catcode 64=11\relax - -\expandafter\ifx\csname @tempcnta\endcsname\relax - \csname newcount\endcsname\@tempcnta -\fi -\expandafter\ifx\csname @tempcntb\endcsname\relax - \csname newcount\endcsname\@tempcntb -\fi - - -\def\luatexsetcatcoderange#1#2#3{% - \edef\luaSCR@temp{% - \noexpand\@tempcnta=\the\@tempcnta - \noexpand\@tempcntb=\the\@tempcntb - \noexpand\count@=\the\count@ - \relax - }% - \@tempcnta=#1\relax - \@tempcntb=#2\relax - \count@=#3\relax - \loop\unless\ifnum\@tempcnta>\@tempcntb - \catcode\@tempcnta=\count@ - \advance\@tempcnta by 1\relax - \repeat - \luaSCR@temp -} - - -\newluatexcatcodetable\CatcodeTableIniTeX -\newluatexcatcodetable\CatcodeTableString -\newluatexcatcodetable\CatcodeTableOther -\newluatexcatcodetable\CatcodeTableLaTeX -\newluatexcatcodetable\CatcodeTableLaTeXAtLetter -\newluatexcatcodetable\CatcodeTableExpl -\initluatexcatcodetable\CatcodeTableIniTeX - -\expandafter\ifx\csname @firstofone\endcsname\relax - \long\def\@firstofone#1{#1}% -\fi - -\begingroup - \def\@makeother#1{\catcode#1=12\relax}% - \@firstofone{% - \luatexcatcodetable\CatcodeTableIniTeX - \begingroup - \luatexsetcatcoderange{0}{8}{15}% - \catcode9=10 % tab - \catcode11=15 % - \catcode12=13 % form feed - \luatexsetcatcoderange{14}{31}{15}% - \catcode35=6 % hash - \catcode36=3 % dollar - \catcode38=4 % ampersand - \catcode94=7 % circumflex - \catcode95=8 % underscore - \catcode123=1 % brace left - \catcode125=2 % brace right - \catcode126=13 % tilde - \catcode127=15 % - \saveluatexcatcodetable\CatcodeTableLaTeX - \catcode64=11 % - \saveluatexcatcodetable\CatcodeTableLaTeXAtLetter - \endgroup - \begingroup - \luatexsetcatcoderange{0}{8}{15}% - \catcode9=9 % tab ignored - \catcode11=15 % - \catcode12=13 % form feed - \luatexsetcatcoderange{14}{31}{15}% - \catcode32=9 % space is ignored - \catcode35=6 % hash mark is macro parameter character - \catcode36=3 % dollar (not so sure about the catcode...) - \catcode38=4 % ampersand - \catcode58=11 % colon letter - \catcode94=7 % circumflex is superscript character - \catcode95=11 % underscore letter - \catcode123=1 % left brace is begin-group character - \catcode125=2 % right brace is end-group character - \catcode126=10 % tilde is a space char. - \catcode127=15 % - \saveluatexcatcodetable\CatcodeTableExpl - \endgroup - \@makeother{0}% nul - \@makeother{13}% carriage return - \@makeother{37}% percent - \@makeother{92}% backslash - \@makeother{127}% - \luatexsetcatcoderange{65}{90}{12}% A-Z - \luatexsetcatcoderange{97}{122}{12}% a-z - \saveluatexcatcodetable\CatcodeTableString - \@makeother{32}% space - \saveluatexcatcodetable\CatcodeTableOther - \endgroup -} - -\ltxtra@AtEnd - -\luadirect{luatextra.catcodetable_do_shortcuts()} - - \let\newluaattribute\newluatexattribute \let\luaattribute\luatexattribute \let\unsetluaattribute\unsetluatexattribute @@ -271,14 +117,11 @@ See the module #1 documentation for explanation.^^J ...^^J}% \let\luaModuleError\luatexModuleError \let\luaRequireModule\luatexRequireModule \let\luaUseModule\luatexUseModule - - \expandafter\ifx\csname ProvidesPackage\endcsname\relax \input luaotfload.sty \else \RequirePackage{luaotfload} \fi - \endinput %% %% End of file `luatextra.sty'. -- cgit v1.2.3