• R/O
  • HTTP
  • SSH
  • HTTPS

luatexja: Commit

ソースコードの管理場所


Commit MetaInfo

Revisionbf7bec46486f83bb9997f27d51a3c19cbe047b15 (tree)
Zeit2018-02-18 10:04:51
AutorHironori Kitagawa <h_kitagawa2001@yaho...>
CommiterHironori Kitagawa

Log Message

stopped to use module(), which is removed in Lua 5.2.

Ändern Zusammenfassung

Diff

--- a/src/ltj-stack.lua
+++ b/src/ltj-stack.lua
@@ -3,12 +3,11 @@
33 --
44 luatexbase.provides_module({
55 name = 'luatexja.stack',
6- date = '2017/05/05',
6+ date = '2018/02/18',
77 description = 'LuaTeX-ja stack system',
88 })
9-module('luatexja.stack', package.seeall)
10-local err, warn, info, log = luatexbase.errwarinf(_NAME)
11-
9+luatexja.stack = {}
10+local ltjs=luatexja.stack
1211 luatexja.load_module('base'); local ltjb = luatexja.base
1312
1413 --------------------------------------------------------------------------------
@@ -21,14 +20,14 @@ local STCK = luatexja.userid_table.STCK
2120 local fastcopy = table.fastcopy
2221 local setcount = tex.setcount
2322 local scan_int, scan_keyword = token.scan_int, token.scan_keyword
24-hmode = 0 -- dummy
23+ltjs.hmode = 0 -- dummy
2524
26-charprop_stack_table={};
27-local charprop_stack_table = charprop_stack_table
25+local charprop_stack_table={};
26+ltjs.charprop_stack_table = charprop_stack_table
2827 charprop_stack_table[0]={}
2928
3029
31-function get_stack_level()
30+local function get_stack_level()
3231 local i = tex.getcount('ltj@@stack')
3332 local j = tex.currentgrouplevel
3433 if j > tex.getcount('ltj@@group@level') then
@@ -43,15 +42,16 @@ function get_stack_level()
4342 charprop_stack_table[i] = fastcopy(charprop_stack_table[i-1])
4443 setcount('ltj@@stack', i)
4544 if gd~=0 then tex.globaldefs = gd end
46- if tex.nest[tex.nest.ptr].mode == -hmode then -- rest. hmode のみ
45+ if tex.nest[tex.nest.ptr].mode == -ltjs.hmode then -- rest. hmode のみ
4746 local g = node_new(id_whatsit, sid_user)
4847 g.user_id=STCK; g.type=100; g.value=j; node.write(g)
4948 end
5049 end
5150 return i
5251 end
52+ltjs.get_stack_level = get_stack_level
5353
54-function set_stack_table(m, p)
54+local function set_stack_table(m, p)
5555 local i = get_stack_level()
5656 charprop_stack_table[i][m] = p
5757 if luatexja.isglobal=='global' then
@@ -60,10 +60,10 @@ function set_stack_table(m, p)
6060 end
6161 end
6262 end
63-local set_stack_table = set_stack_table
63+ltjs.set_stack_table = set_stack_table
6464
6565 -- EXT
66-function set_stack_perchar(m,lb,ub, getter)
66+function ltjs.set_stack_perchar(m,lb,ub, getter)
6767 local c = scan_int()
6868 scan_keyword(',')
6969 local p = tonumber((getter or scan_int)())
@@ -79,7 +79,7 @@ function set_stack_perchar(m,lb,ub, getter)
7979 end
8080
8181 -- EXT
82-function set_stack_font(m,c,p)
82+function ltjs.set_stack_font(m,c,p)
8383 if type(c)~='number' or c<0 or c>255 then
8484 ltjb.package_error('luatexja',
8585 "invalid family number (".. tostring(c) .. ")",
@@ -91,7 +91,7 @@ function set_stack_font(m,c,p)
9191 end
9292
9393 -- EXT: sp: glue_spec
94-function set_stack_skip(m,sp)
94+function ltjs.set_stack_skip(m,sp)
9595 local i = get_stack_level()
9696 if not sp then return end
9797 if not charprop_stack_table[i][m] then
@@ -116,24 +116,25 @@ end
116116
117117 -- These three functions are used in ltj-jfmglue.lua.
118118 -- list_dir and orig_char_table are used in other lua files.
119-orig_char_table = {}
120-list_dir = nil -- dummy
121-table_current_stack = nil -- dummy
122-function report_stack_level(bsl)
123- table_current_stack = charprop_stack_table[bsl]
119+local orig_char_table = {}
120+ltjs.orig_char_table = orig_char_table
121+ltjs.list_dir = nil -- dummy
122+ltjs.table_current_stack = nil -- dummy
123+function ltjs.report_stack_level(bsl)
124+ ltjs.table_current_stack = charprop_stack_table[bsl]
124125 return bsl
125126 end
126-function fast_get_stack_skip(m)
127- return table_current_stack[m]
127+function ltjs.fast_get_stack_skip(m)
128+ return ltjs.table_current_stack[m]
128129 or { width = 0, stretch = 0, shrink = 0, stretch_order = 0, shrink_order = 0 }
129130 end
130131
131132 -- For other situations, use the following instead:
132-function get_stack_skip(m, idx)
133+function ltjs.get_stack_skip(m, idx)
133134 return charprop_stack_table[idx][m]
134135 or { width = 0, stretch = 0, shrink = 0, stretch_order = 0, shrink_order = 0 }
135136 end
136-function get_stack_table(mc, d, idx)
137+function ltjs.get_stack_table(mc, d, idx)
137138 local i = charprop_stack_table[idx][mc]
138139 return i or d
139140 end
--- a/src/ltj-tangle.lua
+++ /dev/null
@@ -1,76 +0,0 @@
1---
2--- luatexja/tangle.lua
3---
4-luatexbase.provides_module({
5- name = 'luatexja.tangle',
6- date = '2011/05/14',
7- description = '',
8-})
9-module('luatexja.tangle', package.seeall)
10-local err, warn, info, log = luatexbase.errwarinf(_NAME)
11-
12---! ixbase0 からの移植
13-
14-local _DONE, _TEX, _STOP = 0, 1, 2
15-local _current_co, _interrupted
16-local _resume, _check
17-
18-local resume_code =
19- "\\directlua{".._NAME..".resume()}\\relax"
20-
21-function execute(func, ...)
22- if _current_co then
23- err("tangle is going now")
24- end
25- local args = { ... }
26- local co = coroutine.create(function()
27- return _DONE, { func(unpack(args)) }
28- end)
29- _current_co = co
30- _interrupted = false
31- return _check(coroutine.resume(co, ...))
32-end
33-
34-function resume()
35- return _resume(false)
36-end
37-
38-function interrupt()
39- return _resume(true)
40-end
41-
42-function run_tex()
43- coroutine.yield(_TEX, {})
44-end
45-
46-function suspend(...)
47- local intr = coroutine.yield(_STOP, { ... })
48- if intr then
49- _interrupted = true
50- error("*INTR*") -- this error is caught later
51- end
52-end
53-
54-function _resume(intr)
55- if not _current_co then
56- err("tangle is not going")
57- end
58- local co = _current_co
59- return _check(coroutine.resume(co, intr))
60-end
61-
62-function _check(costat, tstat, extra)
63- if not costat then -- error in coroutine
64- _current_co = nil
65- if _interrupted then return end
66- err(tstat)
67- elseif tstat == _DONE then
68- _current_co = nil
69- elseif tstat == _TEX then
70- tex.print(resume_code)
71- end
72- return unpack(extra)
73-end
74-
75--- EOF
76-
--- a/src/luatexja.lua
+++ b/src/luatexja.lua
@@ -3,14 +3,7 @@ require('lualibs')
33 tableunpack = table.unpack
44
55 ------------------------------------------------------------------------
6--- naming:
7--- ext_... : called from \directlua{}
8--- int_... : called from other Lua codes, but not from \directlua{}
9--- (other) : only called from this file
10-function luatexja.load_module(name)
11- require('ltj-' .. name.. '.lua')
12-end
13-function luatexja.load_lua(fn)
6+local function load_lua(fn)
147 local found = kpse.find_file(fn, 'tex')
158 if not found then
169 tex.error("LuaTeX-ja error: File `" .. fn .. "' not found")
@@ -19,6 +12,10 @@ function luatexja.load_lua(fn)
1912 dofile(found)
2013 end
2114 end
15+luatexja.load_lua = load_lua
16+function luatexja.load_module(name)
17+ require('ltj-' .. name.. '.lua')
18+end
2219
2320 do
2421 local setfield = node.direct.setfield
@@ -111,7 +108,7 @@ load_module('pretreat'); local ltjp = luatexja.pretreat
111108 load_module('setwidth'); local ltjw = luatexja.setwidth
112109 load_module('jfmglue'); local ltjj = luatexja.jfmglue -- +1 glue +1 gs +1 attr_list
113110 load_module('math'); local ltjm = luatexja.math
114-load_module('tangle'); local ltjb = luatexja.base
111+load_module('base'); local ltjb = luatexja.base
115112
116113
117114 local attr_jchar_class = luatexbase.attributes['ltj@charclass']
Show on old repository browser