OSDN Git Service

Merge commit '5219ca4' into kitagawa_lt20201001
[luatex-ja/luatexja.git] / src / luatexja.lua
1 require 'lualibs'
2 ------------------------------------------------------------------------
3 local function load_lua(fn)
4    local found = kpse.find_file(fn, 'tex')
5    if not found then
6       tex.error("LuaTeX-ja error: File `" .. fn .. "' not found")
7    else
8       texio.write_nl('(' .. found .. ')'); dofile(found)
9    end
10 end
11 luatexja.load_lua = load_lua
12 function luatexja.load_module(name) require('ltj-' .. name.. '.lua') end
13
14 do
15    local setfield = node.direct.setfield
16    luatexja.setglue = node.direct.setglue or
17    function(g,w,st,sh,sto,sho)
18       setfield(g,'width', w or 0); setfield(g,'stretch',st or 0); setfield(g,'shrink', sh or 0)
19       setfield(g,'stretch_order',sto or 0)
20       setfield(g,'shrink_order', sho or 0)
21    end
22    local getfield = node.direct.getfield
23    luatexja.getglue = node.direct.getglue or
24    function(g)
25       return getfield(g,'width'), getfield(g,'stretch'), getfield(g,'shrink'),
26              getfield(g,'stretch_order'), getfield(g,'shrink_order')
27    end
28 end
29
30 --- 以下は全ファイルで共有される定数
31 local icflag_table = {}
32 luatexja.icflag_table = icflag_table
33 icflag_table.ITALIC          = 1
34 icflag_table.PACKED          = 2
35 icflag_table.KINSOKU         = 3
36 icflag_table.FROM_JFM        = 4
37 icflag_table.KANJI_SKIP      = 68 -- = 4+64
38 icflag_table.KANJI_SKIP_JFM  = 69
39 icflag_table.XKANJI_SKIP     = 70
40 icflag_table.XKANJI_SKIP_JFM = 71
41 icflag_table.LINEEND         = 72
42 icflag_table.PROCESSED       = 73
43 icflag_table.IC_PROCESSED    = 74
44 icflag_table.BOXBDD          = 75
45 icflag_table.PROCESSED_BEGIN_FLAG = 4096 -- sufficiently large power of 2
46
47 local stack_ind = {}
48 luatexja.stack_table_index = stack_ind
49 stack_ind.PRE  = 0x200000 -- characterごと
50 stack_ind.POST = 0x400000 -- characterごと
51 stack_ind.KCAT = 0x600000 -- characterごと
52 stack_ind.XSP  = 0x800000 -- characterごと
53 stack_ind.RIPRE  = 0xA00000 -- characterごと,ruby pre
54 stack_ind.RIPOST = 0xC00000 -- characterごと,ruby post
55 stack_ind.JWP  = 0 -- これだけ
56 stack_ind.KSK  = 1 -- これだけ
57 stack_ind.XSK  = 2 -- これだけ
58 stack_ind.MJT  = 0x100 -- 0--255
59 stack_ind.MJS  = 0x200 -- 0--255
60 stack_ind.MJSS = 0x300 -- 0--255
61 stack_ind.KSJ  = 0x400 -- 0--9
62
63 local uid_table = {}
64 luatexja.userid_table = uid_table
65 uid_table.IHB  = luatexbase.newuserwhatsitid('inhibitglue',  'luatexja') -- \inhibitglue
66 uid_table.STCK = luatexbase.newuserwhatsitid('stack_marker', 'luatexja') -- スタック管理
67 uid_table.BPAR = luatexbase.newuserwhatsitid('begin_par',    'luatexja') -- 「段落始め」
68 uid_table.DIR  = luatexbase.newuserwhatsitid('direction',    'luatexja') -- 組方向
69 uid_table.BOXB = luatexbase.newuserwhatsitid('box_boundary', 'luatexja') -- 「ボックス始め・終わり」
70 uid_table.JA_AL_BDD = luatexbase.newuserwhatsitid('ja_al_boundary', 'luatexja')
71
72 local dir_table = {}
73 luatexja.dir_table = dir_table
74 dir_table.dir_dtou = 1
75 dir_table.dir_tate = 3
76 dir_table.dir_yoko = 4
77 dir_table.dir_math_mod    = 8
78 dir_table.dir_node_auto   = 128 -- 組方向を合わせるために自動で作られたもの
79 dir_table.dir_node_manual = 256 -- 寸法代入によって作られたもの
80 dir_table.dir_utod = dir_table.dir_tate + dir_table.dir_math_mod
81   -- 「縦数式ディレクション」 in pTeX
82 --- 定義終わり
83
84 local load_module = luatexja.load_module
85 load_module 'base';      local ltjb = luatexja.base
86 load_module 'rmlgbm';    local ltjr = luatexja.rmlgbm -- must be 1st
87 if luatexja_debug then load_module('debug') end
88 load_module 'lotf_aux';  local ltju = luatexja.lotf_aux
89 load_module 'charrange'; local ltjc = luatexja.charrange
90 load_module 'stack';     local ltjs = luatexja.stack
91 load_module 'direction'; local ltjd = luatexja.direction -- +1 hlist +1 attr_list
92 load_module 'lineskip';  local ltjl = luatexja.lineskip -- +1 hlist +1 attr_list
93 load_module 'jfont';     local ltjf = luatexja.jfont
94 load_module 'inputbuf';  local ltji = luatexja.inputbuf
95 load_module 'pretreat';  local ltjp = luatexja.pretreat
96 load_module 'setwidth';  local ltjw = luatexja.setwidth
97 load_module 'jfmglue';   local ltjj = luatexja.jfmglue -- +1 glue +1 gs +1 attr_list
98 load_module 'math';      local ltjm = luatexja.math
99 load_module 'base';      local ltjb = luatexja.base
100
101 local attr_jchar_class = luatexbase.attributes['ltj@charclass']
102 local attr_jchar_code = luatexbase.attributes['ltj@charcode']
103 local attr_curjfnt = luatexbase.attributes['ltj@curjfnt']
104 local attr_yablshift = luatexbase.attributes['ltj@yablshift']
105 local attr_icflag = luatexbase.attributes['ltj@icflag']
106 local attr_uniqid = luatexbase.attributes['ltj@uniqid']
107 local attr_dir = luatexbase.attributes['ltj@dir']
108 local cat_lp = luatexbase.catcodetables['latex-package']
109
110 -- Three aux. functions, borrowed from tex.web
111
112 local floor = math.floor
113 local function print_scaled(s)
114    local out, delta = '', 10
115    if s<0 then s, out = -s, out..'-' end
116    out=out..tostring(floor(s/65536)) .. '.'
117    s=10*(s%65536)+5
118    repeat
119       if delta>65536 then s=s+32768-50000 end
120       out=out .. tostring(floor(s/65536))
121       s=10*(s%65536); delta=delta*10
122    until s<=delta
123    return out
124 end
125 luatexja.print_scaled = print_scaled
126
127 local function print_glue(d,order)
128    local out=print_scaled(d)
129    if order>0 then
130       out=out..'fi'
131       while order>1 do out=out..'l'; order=order-1 end
132    else out=out..'pt'
133    end
134    return out
135 end
136
137 local function print_spec(p)
138    local out=print_scaled(p.width)..'pt'
139    if p.stretch~=0 then
140       out=out..' plus '..print_glue(p.stretch,p.stretch_order)
141    end
142    if p.shrink~=0 then
143       out=out..' minus '..print_glue(p.shrink,p.shrink_order)
144    end
145 return out
146 end
147
148
149 ------------------------------------------------------------------------
150 -- CODE FOR GETTING/SETTING PARAMETERS
151 ------------------------------------------------------------------------
152
153 -- EXT: print parameters that don't need arguments
154 do
155    local tex_getattr = tex.getattribute
156    local function getattr(a)
157       local r = tex_getattr(a)
158       return (r==-0x7FFFFFFF) and 0 or r
159    end 
160    luatexja.unary_pars = {
161       yalbaselineshift = function(t)
162          return print_scaled(getattr('ltj@yablshift'))..'pt'
163       end,
164       yjabaselineshift = function(t)
165          return print_scaled(getattr('ltj@ykblshift'))..'pt'
166       end,
167       talbaselineshift = function(t)
168          return print_scaled(getattr('ltj@tablshift'))..'pt'
169       end,
170       tjabaselineshift = function(t)
171          return print_scaled(getattr('ltj@tkblshift'))..'pt'
172       end,
173       kanjiskip = function(t)
174          return print_spec(ltjs.get_stack_skip(stack_ind.KSK, t))
175       end,
176       xkanjiskip = function(t)
177          return print_spec(ltjs.get_stack_skip(stack_ind.XSK, t))
178       end,
179       jcharwidowpenalty = function(t)
180          return ltjs.get_stack_table(stack_ind.JWP, 0, t)
181       end,
182       autospacing = function(t)
183          return getattr('ltj@autospc')
184       end,
185       autoxspacing = function(t)
186          return getattr('ltj@autoxspc')
187       end,
188       differentjfm = function(t)
189          local f, r = luatexja.jfmglue.diffmet_rule, '???'
190          if f == math.max then r = 'large'
191          elseif f == math.min then r = 'small'
192          elseif f == math.two_average then r = 'average'
193          elseif f == math.two_paverage then r = 'paverage'
194          elseif f == math.two_pleft then r = 'pleft'
195          elseif f == math.two_pright then r = 'pright'
196          elseif f == math.two_add then r = 'both'
197          end
198          return r
199       end,
200       direction = function()
201          local v = ltjd.get_dir_count()
202          if math.abs(tex.nest[tex.nest.ptr].mode) == ltjs.mmode and v == dir_table.dir_tate then
203             v = dir_table.dir_utod
204          end
205          return v
206       end,
207       adjustdir = ltjd.get_adjust_dir_count,
208    }
209
210    local unary_pars = luatexja.unary_pars
211    local scan_arg = token.scan_argument
212    function luatexja.ext_get_parameter_unary()
213       local k= scan_arg()
214       if unary_pars[k] then
215          tex.write(tostring(unary_pars[k](tex.getcount('ltj@@stack'))))
216       end
217       ltjb.stop_time_measure('get_par')
218    end
219 end
220
221
222 -- EXT: print parameters that need arguments
223 do
224    luatexja.binary_pars = {
225       jacharrange = function(c, t)
226          if type(c)~='number' or c<-1 or c>31*ltjc.ATTR_RANGE then
227             -- 0, -1 はエラーにしない(隠し)
228             ltjb.package_error('luatexja',
229                                'invalid character range number (' .. tostring(c) .. ')',
230                                'A character range number should be in the range 1..'
231                                .. 31*ltjc.ATTR_RANGE .. ",\n"..
232                                'So I changed this one to ' .. 31*ltjc.ATTR_RANGE .. ".")
233             c=0 -- external range 217 == internal range 0
234          elseif c==31*ltjc.ATTR_RANGE then c=0
235          end
236       -- 負の値は <U+0080 の文字の文字範囲,として出てくる.この時はいつも欧文文字なので 1 を返す
237          return (c<0) and 1 or ltjc.get_range_setting(c)
238       end,
239       prebreakpenalty = function(c, t)
240          return ltjs.get_stack_table(stack_ind.PRE + ltjb.in_unicode(c, true), 0, t)
241       end,
242       postbreakpenalty = function(c, t)
243          return ltjs.get_stack_table(stack_ind.POST + ltjb.in_unicode(c, true), 0, t)
244       end,
245       kcatcode = function(c, t)
246          return ltjs.get_stack_table(stack_ind.KCAT + ltjb.in_unicode(c, false), 0, t)
247       end,
248       chartorange = function(c, t)
249          return ltjc.char_to_range(ltjb.in_unicode(c, false))
250       end,
251       jaxspmode = function(c, t)
252          return ltjs.get_stack_table(stack_ind.XSP + ltjb.in_unicode(c, true), 3, t)
253       end,
254       boxdir = function(c, t)
255          if type(c)~='number' or c<0 or c>65535 then
256             ltjb.package_error('luatexja',
257                                'Bad register code (' .. tostring(c) .. ')',
258                                'A register must be between 0 and 65535.\n'..
259                                'I changed this one to zero.')
260             c=0
261          end
262          return ltjd.get_register_dir(c)
263       end,
264    }
265    local binary_pars = luatexja.binary_pars
266    local scan_arg, scan_int = token.scan_argument, token.scan_int
267    binary_pars.alxspmode = binary_pars.jaxspmode
268    function luatexja.ext_get_parameter_binary(k, c)
269       if binary_pars[k] then
270          tex.write(tostring(binary_pars[k](c,tex.getcount('ltj@@stack'))))
271       end
272       ltjb.stop_time_measure('get_par')
273    end
274 end
275
276 -- EXT: print \global if necessary
277 function luatexja.ext_print_global()
278    if luatexja.isglobal=='global' then tex.sprint(cat_lp, '\\global') end
279 end
280
281
282 -- main process
283 do
284    local start_time_measure, stop_time_measure
285       = ltjb.start_time_measure, ltjb.stop_time_measure
286    local nullfunc = function (n) return n end
287    local to_node = node.direct.tonode
288    local to_direct = node.direct.todirect
289    local ensure_tex_attr = ltjb.ensure_tex_attr
290
291    -- mode = true iff main_process is called from pre_linebreak_filter
292    local function main_process(head, mode, dir, gc)
293       ensure_tex_attr(attr_icflag, 0)
294       if gc == 'fin_row' then return head
295       else
296             start_time_measure('jfmglue')
297             local p = ltjj.main(to_direct(head),mode, dir)
298             stop_time_measure('jfmglue')
299             return to_node(p)
300       end
301    end
302
303    local function adjust_icflag(h)
304       -- kern from luaotfload will have icflag = 1
305       -- (same as italic correction)
306       ensure_tex_attr(attr_icflag, 1)
307       return h
308    end
309
310    -- callbacks
311    ltjb.add_to_callback(
312       'pre_linebreak_filter',
313       function (head,groupcode)
314          return main_process(head, true, tex.textdir, groupcode)
315       end,'ltj.main',
316       luatexbase.priority_in_callback('pre_linebreak_filter', 'luaotfload.node_processor')+1)
317    ltjb.add_to_callback(
318       'hpack_filter',
319       function (head,groupcode,size,packtype, dir)
320          return main_process(head, false, dir, groupcode)
321       end,'ltj.main',
322       luatexbase.priority_in_callback('hpack_filter', 'luaotfload.node_processor')+1)
323    ltjb.add_to_callback('pre_linebreak_filter', adjust_icflag, 'ltj.adjust_icflag', 1)
324    ltjb.add_to_callback('hpack_filter', adjust_icflag, 'ltj.adjust_icflag', 1)
325 end
326
327 -- cleanup process
328 function luatexja.ext_cleanup()
329    ltjf.cleanup_size_cache(); ltjd.remove_end_whatsit()
330 end
331
332 -- lastnodechar
333 do
334    local id_glyph = node.id('glyph')
335    function luatexja.pltx_composite_last_node_char()
336       local n = tex.nest[tex.nest.ptr].tail
337       local r = '-1'
338       if n then
339          if n.id==id_glyph then
340             while n.componetns and  n.subtype and n.subtype%4 >= 2 do
341                n = node.tail(n)
342             end
343             r = tostring(n.char)
344          end
345       end
346       tex.sprint(r)
347    end
348 end
349
350 do
351     local cache_ver = 1 -- must be same as ltj-kinsoku.tex
352     local cache_outdate_fn = function (t) return t.version~=cache_ver end
353     local t = luatexja.stack.charprop_stack_table
354     function luatexja.load_kinsoku()
355         for i,_ in pairs(t) do t[i]=nil; end
356         tex.setcount('ltj@@stack',0)
357         local kinsoku = ltjb.load_cache('ltj-kinsoku',cache_outdate_fn)
358         t[0] = kinsoku and kinsoku[1] or {}
359         if t[0] then
360             tex.print(cat_lp, '\\input ltj-kinsoku.tex\\relax')
361         end
362         luatexja.load_kinsoku=nil
363     end
364 end
365
366 -- debug
367
368 do
369
370 local node_type = node.type
371 local node_next = node.next
372 local has_attr = node.has_attribute
373
374 local id_penalty = node.id('penalty')
375 local id_glyph = node.id('glyph')
376 local id_glue = node.id('glue')
377 local id_kern = node.id('kern')
378 local id_hlist = node.id('hlist')
379 local id_vlist = node.id('vlist')
380 local id_rule = node.id('rule')
381 local id_math = node.id('math')
382 local id_whatsit = node.id('whatsit')
383 local sid_user = node.subtype('user_defined')
384
385 local prefix, inner_depth
386 local utfchar = utf.char
387 local function debug_show_node_X(p,print_fn, limit, inner_depth)
388    local k = prefix
389    local s
390    local pt, pic = node_type(p.id), (has_attr(p, attr_icflag) or 0) % icflag_table.PROCESSED_BEGIN_FLAG
391    local base = prefix .. string.format('%X', pic) .. ' ' .. pt .. ' ' .. tostring(p.subtype) .. ' '
392    if pt == 'glyph' then
393       s = base .. ' ' 
394           .. (p.char<0xF0000 and utfchar(p.char) or '') 
395           .. string.format(' (U+%X) ', p.char)
396           .. tostring(p.font) .. ' (' .. print_scaled(p.height) .. '+'
397           .. print_scaled(p.depth) .. ')x' .. print_scaled(p.width)
398       if p.xoffset~=0 or p.yoffset~=0 then
399          s = s .. ' off: (' .. print_scaled(p.xoffset)
400                .. ',' .. print_scaled(p.yoffset) .. ')'
401       end
402       print_fn(s)
403    elseif pt=='hlist' or pt=='vlist' or pt=='unset'or pt=='ins' then
404       if pt=='ins' then
405          s = base .. '(' .. print_scaled(p.height) .. '+'
406             .. print_scaled(p.depth) .. ')'
407             .. ', dir=' .. tostring(node.has_attribute(p, attr_dir))
408       else
409          s = base .. '(' .. print_scaled(p.height) .. '+'
410             .. print_scaled(p.depth) .. ')x' .. print_scaled(p.width)
411             .. ', dir=' .. tostring(node.has_attribute(p, attr_dir))
412       end
413       if (p.shift or 0)~=0 then
414          s = s .. ', shifted ' .. print_scaled(p.shift)
415       end
416       if p.glue_set and p.glue_sign ==2 or ( p.glue_sign==1 and p.glue_set>0) then
417          s = s .. ' glue set '
418          if p.glue_sign == 2 then s = s .. '-' end
419          s = s .. tostring(floor(p.glue_set*10000)/10000)
420          if p.glue_order == 0 then s = s .. 'pt'
421          else
422             s = s .. 'fi'
423             for i = 2, p.glue_order do s = s .. 'l' end
424          end
425       end
426       if pic == icflag_table.PACKED then s = s .. ' (packed)' end
427       print_fn(s);
428       local bid = inner_depth
429       prefix, inner_depth = prefix.. '.', inner_depth + 1
430       if inner_depth < limit then
431          for q in node.traverse(p.head) do
432             debug_show_node_X(q, print_fn, limit, inner_depth)
433          end
434       end
435       prefix=k
436    elseif pt=='rule' then
437       s = base .. '(' .. print_scaled(p.height) .. '+'
438          .. print_scaled(p.depth) .. ')x' .. print_scaled(p.width)
439          .. ', dir=' .. tostring(node.has_attribute(p, attr_dir))
440       print_fn(s)
441    elseif pt=='disc' then
442       print_fn(s)
443       local bid = inner_depth
444       if inner_depth < limit then
445          prefix, inner_depth = k.. 'p.', inner_depth + 1
446          for q in node.traverse(p.pre) do
447             debug_show_node_X(q, print_fn, limit, inner_depth)
448          end
449          prefix = k.. 'P.'
450          for q in node.traverse(p.post) do
451             debug_show_node_X(q, print_fn, limit, inner_depth)
452          end
453          prefix = k.. 'R.'
454          for q in node.traverse(p.replace) do
455             debug_show_node_X(q, print_fn, limit, inner_depth)
456          end
457       end
458       prefix=k
459    elseif pt == 'glue' then
460       s = base .. ' ' ..  print_spec(p)
461       if pic>icflag_table.KINSOKU and pic<icflag_table.KANJI_SKIP then
462          s = s .. ' (from JFM: priority ' .. pic-icflag_table.FROM_JFM .. ')'
463       elseif pic==icflag_table.KANJI_SKIP then
464          s = s .. ' (kanjiskip)'
465       elseif pic==icflag_table.KANJI_SKIP_JFM then
466          s = s .. ' (kanjiskip, JFM specified)'
467       elseif pic==icflag_table.XKANJI_SKIP then
468          s = s .. ' (xkanjiskip)'
469       elseif pic==icflag_table.XKANJI_SKIP_JFM then
470          s = s .. ' (xkanjiskip, JFM specified)'
471       end
472       print_fn(s)
473    elseif pt == 'kern' then
474       s = base .. ' ' .. print_scaled(p.kern) .. 'pt'
475       if p.subtype==2 then
476          s = s .. ' (for accent)'
477       elseif pic==icflag_table.IC_PROCESSED then
478          s = s .. ' (italic correction)'
479       elseif pic==icflag_table.LINEEND then
480          s = s .. ' (end-of-line)'
481       elseif pic>icflag_table.KINSOKU
482          and pic<icflag_table.KANJI_SKIP then
483          s = s .. ' (from JFM: priority ' .. pic-icflag_table.FROM_JFM .. ')'
484       end
485       print_fn(s)
486    elseif pt == 'penalty' then
487       s = base .. ' ' .. tostring(p.penalty)
488       if pic==icflag_table.KINSOKU then s = s .. ' (for kinsoku)' end
489       print_fn(s)
490    elseif pt == 'dir' then
491       print_fn(base .. ' ' .. tostring(p.dir) .. ' (level ' .. tostring(p.level) .. ')')
492    elseif pt == 'whatsit' then
493       s = base
494       if p.subtype==sid_user then
495          local t = tostring(p.user_id) .. ' (' ..
496             luatexbase.get_user_whatsit_name(p.user_id) .. ') '
497          if p.type ~= 110 then
498             s = s .. ' userid:' .. t .. p.value
499             print_fn(s)
500          else
501             s = s .. ' userid:' .. t .. '(node list)'
502             if p.user_id==uid_table.DIR then
503                s = s .. ' dir: ' .. tostring(node.has_attribute(p, attr_dir))
504             end
505             print_fn(s)
506             local bid = inner_depth
507             prefix, inner_depth = prefix.. '.', inner_depth + 1
508             if inner_depth < limit then
509                for q in node.traverse(p.value) do
510                   debug_show_node_X(q, print_fn, limit, inner_depth)
511                end
512             end
513             prefix, inner_depth = k, bid
514          end
515       else
516          s = s .. (node.subtype(p.subtype) or '')
517          if p.subtype==1 then
518             s = s .. ' stream=' .. p.stream
519             print_fn(s)
520             for i=1,#p.data do
521                print_fn(s .. '  [' .. i .. '] = ' .. tostring(p.data[i].csname))
522             end
523          elseif p.subtype==16 then
524             s = s .. ' mode=' .. p.mode .. ', literal="' .. p.data .. '"'
525             print_fn(s)
526          else
527             print_fn(s)
528          end
529       end
530    -------- math node --------
531    elseif pt=='noad' then
532       print_fn(base)
533       if p.nucleus then
534          prefix = k .. 'N'; debug_show_node_X(p.nucleus, print_fn, limit, inner_depth);
535       end
536       if p.sup then
537          prefix = k .. '^'; debug_show_node_X(p.sup, print_fn, limit, inner_depth);
538       end
539       if p.sub then
540          prefix = k .. '_'; debug_show_node_X(p.sub, print_fn, limit, inner_depth);
541       end
542       prefix = k;
543    elseif pt=='math_char' then
544       s = base .. ' fam: ' .. p.fam .. ' , char = ' .. utfchar(p.char)
545       print_fn(s)
546    elseif pt=='sub_box' or pt=='sub_mlist' then
547       print_fn(base)
548       if p.head then
549          prefix = k .. '.';
550          for q in node.traverse(p.head) do
551             debug_show_node_X(q, print_fn, limit, inner_depth)
552          end
553       end
554    else
555       print_fn(base)
556    end
557    p=node_next(p)
558 end
559 function luatexja.ext_show_node_list(head,depth,print_fn, lim)
560    prefix = depth
561    inner_depth = 0
562    if head then
563       while head do
564          debug_show_node_X(head, print_fn, lim or 1/0, inner_depth); head = node_next(head)
565       end
566    else
567       print_fn(prefix .. ' (null list)')
568    end
569 end
570 function luatexja.ext_show_node(head,depth,print_fn, lim)
571    prefix = depth
572    inner_depth = 0
573    if head then
574       debug_show_node_X(head, print_fn, lim or 1/0, inner_depth)
575    else
576       print_fn(prefix .. ' (null list)')
577    end
578 end
579
580 end