• R/O
  • HTTP
  • SSH
  • HTTPS

luatexja: コミット

ソースコードの管理場所


コミットメタ情報

リビジョン50b367ca94bc145d6231d00c65d3447672d83a9d (tree)
日時2011-06-05 20:27:09
作者Takayuki YATO <zrbabbler@user...>
コミッターTakayuki YATO

ログメッセージ

Fixed a comment bug in infomute.lua.

- Register allocation in Lua.

変更サマリ

差分

--- a/src/luatexja-base.sty
+++ b/src/luatexja-base.sty
@@ -16,10 +16,19 @@
1616 \ProvidesPackage{luatexja-base}[2011/04/01 v0.1]
1717 \fi %</LaTeX>
1818
19+
20+%%------------------ Lua module loading
21+
1922 %% Quark tokens needed in Lua modules.
2023 \protected\def\ltj@@q@escape{\ltj@@q@escape@}
2124 \protected\def\ltj@@q@escapenum{\ltj@@q@escapenum@}
2225
26+%%
27+\countdef\ltj@@count@zero=0 %
28+\luatexattributedef\ltj@@attr@zero=0 %
29+\dimendef\ltj@@dimen@zero=0 %
30+\skipdef\ltj@@skip@zero=0 %
31+
2332 %% Load Lua modules.
2433 \RequireLuaModule{luatexja.base}
2534 \RequireLuaModule{luatexja.tangle}
--- a/src/luatexja/base.lua
+++ b/src/luatexja/base.lua
@@ -14,6 +14,113 @@ local ltb = luatexbase
1414 local tostring = tostring
1515 local node, table, tex, token = node, table, tex, token
1616
17+--------------------
18+
19+public_name = 'luatexja'
20+public_version = 'alpha'
21+
22+-------------------- Fully-expandable error messaging
23+do
24+--! LaTeX 形式のエラーメッセージ(\PackageError 等)を
25+--! Lua 関数の呼び出しで行う.
26+
27+ local LF = "\n"
28+ local err_break = ""
29+ local err_main = ""
30+ local err_help = ""
31+
32+ local function message_cont(str, c)
33+ return str:gsub(err_break, LF .. c)
34+ end
35+ local function into_lines(str)
36+ return str:gsub(err_break, LF):explode(LF)
37+ end
38+
39+ function _error_set_break(str)
40+ err_break = str
41+ end
42+
43+ function _error_set_message(msgcont, main, help)
44+ err_main = message_cont(main, msgcont)
45+ err_help = into_lines(help)
46+ end
47+
48+ function _error_show(escchar)
49+ local escapechar = tex.escapechar
50+ local newlinechar = tex.newlinechar
51+ local errorcontextlines = tex.errorcontextlines
52+ if not escchar then tex.escapechar = -1 end
53+ tex.newlinechar = 10
54+ tex.errorcontextlines = -1
55+ tex.error(err_main, err_help)
56+ tex.escapechar = escapechar
57+ tex.newlinechar = newlinechar
58+ tex.errorcontextlines = errorcontextlines
59+ end
60+
61+ local message_a = "Type H <return> for immediate help"
62+
63+ function generic_error(msgcont, main, ref, help)
64+ local mainref = main..".\n\n"..ref.."\n"..message_a
65+ _error_set_message(msgcont, mainref, help)
66+ _error_show(true)
67+ end
68+
69+ function _generic_warn_info(msgcont, main, warn, line)
70+ local mainc = message_cont(main, msgcont)
71+ local br = warn and "\n" or ""
72+ local out = warn and "term and log" or "log"
73+ local on_line = line and (" on input line "..tex.inputlineno) or ""
74+ local newlinechar = tex.newlinechar
75+ tex.newlinechar = -1
76+ texio.write_nl(out, br..main..on_line.."."..br)
77+ tex.newlinechar = newlinechar
78+ end
79+
80+ function generic_warning(msgcont, main)
81+ _generic_warn_info(msgcont, main, true, true)
82+ end
83+ function generic_warning_no_line(msgcont, main)
84+ _generic_warn_info(msgcont, main, true, false)
85+ end
86+ function generic_info(msgcont, main)
87+ _generic_warn_info(msgcont, main, false, true)
88+ end
89+ function generic_info_no_line(msgcont, main)
90+ _generic_warn_info(msgcont, main, false, false)
91+ end
92+
93+ function package_error(pkgname, main, help)
94+ generic_error("("..pkgname.." ",
95+ "Package "..pkgname.." Error: "..main,
96+ "See the "..pkgname.." package documentation for explanation.",
97+ help)
98+ end
99+ function package_warning(pkgname, main)
100+ generic_warning("("..pkgname.." ",
101+ "Package "..pkgname.." Warning: "..main)
102+ end
103+ function package_warning_no_line(pkgname, main)
104+ generic_warning_no_line("("..pkgname.." ",
105+ "Package "..pkgname.." Warning: "..main)
106+ end
107+ function package_info(pkgname, main)
108+ generic_info("("..pkgname.." ",
109+ "Package "..pkgname.." Info: "..main)
110+ end
111+ function package_info_no_line(pkgname, main)
112+ generic_info_no_line("("..pkgname.." ",
113+ "Package "..pkgname.." Info: "..main)
114+ end
115+
116+ function ltj_error(main, help)
117+ package_error(public_name, main, help)
118+ end
119+ function ltj_warning_no_line(main)
120+ package_warning_no_line(public_name, main, help)
121+ end
122+
123+end
17124 -------------------- TeX stream I/O
18125 do
19126
@@ -135,101 +242,6 @@ do
135242 --! ixbase.length は tex.skip と全く同じなので不要.
136243
137244 end
138--------------------- Fully-expandable error messaging
139-do
140---! LaTeX 形式のエラーメッセージ(\PackageError 等)を
141---! Lua 関数の呼び出しで行う.
142-
143- local LF = "\\n"
144- local err_break = ""
145- local err_main = ""
146- local err_help = ""
147-
148- local function message_cont(str, c)
149- return str:gsub(err_break, LF .. c)
150- end
151- local function into_lines(str)
152- return str:gsub(err_break, LF):explode(LF)
153- end
154-
155- function _error_set_break(str)
156- err_break = str
157- end
158-
159- function _error_set_message(msgcont, main, help)
160- err_main = message_cont(main, msgcont)
161- err_help = into_lines(help)
162- end
163-
164- function _error_show(escchar)
165- local escapechar = tex.escapechar
166- local newlinechar = tex.newlinechar
167- local errorcontextlines = tex.errorcontextlines
168- if not escchar then tex.escapechar = -1 end
169- tex.newlinechar = 10
170- tex.errorcontextlines = -1
171- tex.error(err_main, err_help)
172- tex.escapechar = escapechar
173- tex.newlinechar = newlinechar
174- tex.errorcontextlines = errorcontextlines
175- end
176-
177- local message_a = "Type H <return> for immediate help"
178-
179- function generic_error(msgcont, main, ref, help)
180- local mainref = main..".\n\n"..ref.."\n"..message_a
181- _error_set_message(msgcont, mainref, help)
182- _error_show(true)
183- end
184-
185- function _generic_warn_info(msgcont, main, warn, line)
186- local mainc = message_cont(main, msgcont)
187- local br = warn and "\n" or ""
188- local out = warn and "term and log" or "log"
189- local on_line = line and (" on input line "..tex.inputlineno) or ""
190- local newlinechar = tex.newlinechar
191- tex.newlinechar = -1
192- texio.write_nl(out, br..main..on_line.."."..br)
193- tex.newlinechar = newlinechar
194- end
195-
196- function generic_warning(msgcont, main)
197- _generic_warn_info(msgcont, main, true, true)
198- end
199- function generic_warning_no_line(msgcont, main)
200- _generic_warn_info(msgcont, main, true, false)
201- end
202- function generic_info(msgcont, main)
203- _generic_warn_info(msgcont, main, false, true)
204- end
205- function generic_info_no_line(msgcont, main)
206- _generic_warn_info(msgcont, main, false, false)
207- end
208-
209- function package_error(pkgname, main, help)
210- generic_error("("..pkgname.." ",
211- "Package "..pkgname.." Error: "..main,
212- "See the "..pkgname.." package documentation for explanation.",
213- help)
214- end
215- function package_warning(pkgname, main)
216- generic_warning("("..pkgname.." ",
217- "Package "..pkgname.." Warning: "..main)
218- end
219- function package_warning_no_line(pkgname, main)
220- generic_warning_no_line("("..pkgname.." ",
221- "Package "..pkgname.." Warning: "..main)
222- end
223- function package_info(pkgname, main)
224- generic_info("("..pkgname.." ",
225- "Package "..pkgname.." Info: "..main)
226- end
227- function package_info_no_line(pkgname, main)
228- generic_info_no_line("("..pkgname.." ",
229- "Package "..pkgname.." Info: "..main)
230- end
231-
232-end
233245 -------------------- Number handling in TeX source
234246 do
235247
@@ -372,6 +384,39 @@ do
372384 end
373385
374386 end
387+-------------------- TeX register allocation
388+do
389+ local cmod_base_count = token.create('ltj@@count@zero')[2]
390+ local cmod_base_attr = token.create('ltj@@attr@zero')[2]
391+ local cmod_base_dimen = token.create('ltj@@dimen@zero')[2]
392+ local cmod_base_skip = token.create('ltj@@skip@zero')[2]
393+
394+ function const_number(name)
395+ if name:sub(1, 1) == '\\' then name = name:sub(2) end
396+ return token.create(name)[2]
397+ end
398+
399+ function count_number(name)
400+ if name:sub(1, 1) == '\\' then name = name:sub(2) end
401+ return token.create(name)[2] - cmod_base_count
402+ end
403+
404+ function attribute_number(name)
405+ if name:sub(1, 1) == '\\' then name = name:sub(2) end
406+ return token.create(name)[2] - cmod_base_attr
407+ end
408+
409+ function dimen_number(name)
410+ if name:sub(1, 1) == '\\' then name = name:sub(2) end
411+ return token.create(name)[2] - cmod_base_dimen
412+ end
413+
414+ function skip_number(name)
415+ if name:sub(1, 1) == '\\' then name = name:sub(2) end
416+ return token.create(name)[2] - cmod_base_skip
417+ end
418+
419+end
375420 -------------------- mock of debug logger
376421
377422 if not _M.debug or _M.debug == _G.debug then
--- a/src/luatexja/infomute.lua
+++ b/src/luatexja/infomute.lua
@@ -47,7 +47,7 @@ local function apply_patch()
4747 patch_applied = true
4848 end
4949
50-!-- モジュール mod の情報出力を抑止する.
50+--! モジュール mod の情報出力を抑止する.
5151 function add_mute(mod)
5252 info_mute[mod] = true
5353 if not patch_applied then
旧リポジトリブラウザで表示