diff options
author | Hironobu Yamashita <h.y.acetaminophen@gmail.com> | 2021-06-25 09:24:54 +0000 |
---|---|---|
committer | Hironobu Yamashita <h.y.acetaminophen@gmail.com> | 2021-06-25 09:24:54 +0000 |
commit | e481dc9146719345547c7554d9259c923d2846ae (patch) | |
tree | dda50c9ca7da179adbb31051a1138eb7eeb02e2a /Build | |
parent | 8d8684458b9d43c49479394b5411f999bfc0f154 (diff) |
ptex: fix searching in inhibit/kinsoku tables
git-svn-id: svn://tug.org/texlive/trunk@59700 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r-- | Build/source/texk/web2c/ptexdir/ChangeLog | 10 | ||||
-rw-r--r-- | Build/source/texk/web2c/ptexdir/ptex-base.ch | 62 | ||||
-rw-r--r-- | Build/source/texk/web2c/ptexdir/tests/kinsoku_search.tex | 43 | ||||
-rw-r--r-- | Build/source/texk/web2c/ptexdir/tests/kinsoku_table.tex | 29 | ||||
-rw-r--r-- | Build/source/texk/web2c/uptexdir/ChangeLog | 2 |
5 files changed, 113 insertions, 33 deletions
diff --git a/Build/source/texk/web2c/ptexdir/ChangeLog b/Build/source/texk/web2c/ptexdir/ChangeLog index cf8e1e62b56..9f6c2c00c34 100644 --- a/Build/source/texk/web2c/ptexdir/ChangeLog +++ b/Build/source/texk/web2c/ptexdir/ChangeLog @@ -7,8 +7,14 @@ and it is a disp_node. https://github.com/texjporg/tex-jp-build/issues/123 * ptex-base.ch: Partially revert the commit on 2019-05-06; - no re-eval kcatcode of Japanese character token in \if and \ifcat. - This is because the behavior was inconsistent against \ifx. + no re-eval kcatcode of \let-copied Japanese character token in + \if and \ifcat, because the behavior was inconsistent against \ifx. + https://github.com/texjporg/ptex-manual/issues/4 + * ptex-base.ch: Fix searching in inhibit/kinsoku tables, because + the fix on 2018-04-14 was still incomplete. + https://github.com/texjporg/tex-jp-build/issues/113 + * tests/kinsoku_search.tex: New test file. + * tests/kinsoku_table.tex: Update. 2021-03-23 Karl Berry <karl@tug.org> diff --git a/Build/source/texk/web2c/ptexdir/ptex-base.ch b/Build/source/texk/web2c/ptexdir/ptex-base.ch index 0cee7df6b36..b9e4fc96e00 100644 --- a/Build/source/texk/web2c/ptexdir/ptex-base.ch +++ b/Build/source/texk/web2c/ptexdir/ptex-base.ch @@ -1249,10 +1249,27 @@ if n<math_code_base then begin print_esc("xspcode"); print_int(n-auto_xsp_code_base); end else if n<kinsoku_base then - begin print("(inhibitxspcode table) "); print_int(n-inhibit_xsp_code_base); + begin print("inhibitxspcode table "); print_int(n-inhibit_xsp_code_base); + print(", type="); + case eq_type(n) of + 0: print("both"); { |inhibit_both| } + 1: print("before"); { |inhibit_previous| } + 2: print("after"); { |inhibit_after| } + 3: print("none"); { |inhibit_none| } + 4: print("unused"); { |inhibit_unused| } + end; {there are no other cases} + print(", code"); end else if n<kansuji_base then - begin print("(kinsoku table) "); print_int(n-kinsoku_base); + begin print("kinsoku table "); print_int(n-kinsoku_base); + print(", type="); + case eq_type(n) of + 0: print("no"); + 1: print("pre"); { |pre_break_penalty_code| } + 2: print("post"); { |post_break_penalty_code| } + 3: print("unused"); { |kinsoku_unused_code| } + end; {there are no other cases} + print(", code"); end else if n<lc_code_base then begin print_esc("kansujichar"); print_int(n-kansuji_base); @@ -1412,7 +1429,10 @@ end; tats @y else if n<kinsoku_penalty_base then @<Show equivalent |n|, in region 6@> -else if n<=eqtb_size then print("kinsoku") +else if n<=eqtb_size then begin + print("kinsoku table "); print_int(n-kinsoku_penalty_base); + print(", penalty="); print_int(eqtb[n].int); + end else print_char("?"); {this can't happen either} end; tats @@ -6582,19 +6602,23 @@ assign_inhibit_xsp_code: print_esc("inhibitxspcode"); @ @<Declare procedures needed in |scan_something_internal|@>= function get_inhibit_pos(c:KANJI_code; n:small_number):pointer; label done, done1; -var p,s:pointer; -begin s:=calc_pos(c); p:=s; +var p,pp,s:pointer; +begin s:=calc_pos(c); p:=s; pp:=no_entry; if n=new_pos then begin repeat - if (inhibit_xsp_type(p)=inhibit_unused)or(inhibit_xsp_code(p)=0) - or(inhibit_xsp_code(p)=c) then goto done; + if inhibit_xsp_code(p)=c then goto done; { found, update there } + if inhibit_xsp_code(p)=0 then { no further scan needed } + begin if pp<>no_entry then p:=pp; goto done; end; + if inhibit_xsp_type(p)=inhibit_unused then + if pp=no_entry then pp:=p; { save the nearest unused hash } incr(p); if p>255 then p:=0; - until s=p; p:=no_entry; + until s=p; + p:=pp; end else begin repeat - if inhibit_xsp_code(p)=0 then goto done1 - else if (inhibit_xsp_type(p)<>inhibit_unused)and(inhibit_xsp_code(p)=c) then goto done; + if inhibit_xsp_code(p)=0 then goto done1; + if inhibit_xsp_code(p)=c then goto done; incr(p); if p>255 then p:=0; until s=p; done1: p:=no_entry; @@ -6629,6 +6653,7 @@ end; begin scan_int; q:=get_inhibit_pos(tokanji(cur_val),cur_pos); cur_val_level:=int_val; cur_val:=inhibit_none; if q<>no_entry then cur_val:=inhibit_xsp_type(q); +if cur_val>inhibit_none then cur_val:=inhibit_none; end @ The \.{\\prebreakpenalty} is used to specified amount of penalties inserted @@ -6654,8 +6679,8 @@ assign_kinsoku: case chr_code of @ @<Declare procedures needed in |scan_something_internal|@>= function get_kinsoku_pos(c:KANJI_code; n:small_number):pointer; label done, done1; -var p,s:pointer; -begin s:=calc_pos(c); p:=s; +var p,pp,s:pointer; +begin s:=calc_pos(c); p:=s; pp:=no_entry; @!debug print_ln; print("c:="); print_int(c); print(", p:="); print_int(s); if p+kinsoku_base<0 then @@ -6664,16 +6689,19 @@ if p+kinsoku_base<0 then gubed if n=new_pos then begin repeat - if (kinsoku_type(p)=0)or(kinsoku_type(p)=kinsoku_unused_code) - or(kinsoku_code(p)=c) then goto done; + if kinsoku_code(p)=c then goto done; { found, update there } + if kinsoku_type(p)=0 then { no further scan needed } + begin if pp<>no_entry then p:=pp; goto done; end; + if kinsoku_type(p)=kinsoku_unused_code then + if pp=no_entry then pp:=p; { save the nearest unused hash } incr(p); if p>255 then p:=0; until s=p; - p:=no_entry; + p:=pp; end else begin repeat - if kinsoku_type(p)=0 then goto done1 - else if (kinsoku_type(p)<>kinsoku_unused_code)and(kinsoku_code(p)=c) then goto done; + if kinsoku_type(p)=0 then goto done1; + if kinsoku_code(p)=c then goto done; incr(p); if p>255 then p:=0; until s=p; done1: p:=no_entry; diff --git a/Build/source/texk/web2c/ptexdir/tests/kinsoku_search.tex b/Build/source/texk/web2c/ptexdir/tests/kinsoku_search.tex new file mode 100644 index 00000000000..e59445e7d9c --- /dev/null +++ b/Build/source/texk/web2c/ptexdir/tests/kinsoku_search.tex @@ -0,0 +1,43 @@ +%#!euptex -ini -etex +\tracingonline1 +\tracingassigns1 + +% 最優先hashはコードポイントから一意に決まる値(jtex.pdfも参照) +\prebreakpenalty`、=10000 % code=12289, 最優先hash=1 +\prebreakpenalty`。=10000 % code=12290, 最優先hash=2 +\prebreakpenalty`ぁ=150 % code=12353, 最優先hash=1だが埋まってしまったので3に分配 +\prebreakpenalty`ぃ=150 % code=12355, 最優先hash=3だが埋まってしまったので4に分配 + +\showthe\currentgrouplevel % > 0. +\showthe\prebreakpenalty`ぃ % > 150. + +\prebreakpenalty`ぃ=0 % changing hash=4 +\showthe\prebreakpenalty`ぃ % > 0. ← OK(hash=4読出) + +\prebreakpenalty`ぃ=123 % changing hash=4 +\showthe\prebreakpenalty`ぃ % > 123. ← OK(hash=4読出) + +\prebreakpenalty`ぁ=0 % changing hash=3 +\showthe\prebreakpenalty`ぃ % > 123. ← OK(hash=4読出) + +% この時点で "ぁ" が消えてhash=3が空いている。 +% 一方,"ぃ"はフォールバックしたhash=4に格納されている。 + +\prebreakpenalty`ぃ=0 % changing hash=4 +\showthe\prebreakpenalty`ぃ % > 0. ← 修正(削除済み) + +\prebreakpenalty`ぃ=234 % changing hash=3 +\showthe\prebreakpenalty`ぃ % > 234. ← OK(hash=3読出) + +\prebreakpenalty`ぃ=0 % changing hash=3 +\showthe\prebreakpenalty`ぃ % > 0. ← 修正(削除済み) + +\prebreakpenalty`ぁ=345 % changing hash=3 +\showthe\prebreakpenalty`ぃ % > 0. ← 修正(削除済み) + +% この時点で "ぁ" が再びhash=3を埋めている。 + +\prebreakpenalty`ぃ=0 % reassigning hash=4 +\showthe\prebreakpenalty`ぃ % > 0. ← OK(削除済み) + +\end diff --git a/Build/source/texk/web2c/ptexdir/tests/kinsoku_table.tex b/Build/source/texk/web2c/ptexdir/tests/kinsoku_table.tex index bece61cd0c6..52b21fdbf86 100644 --- a/Build/source/texk/web2c/ptexdir/tests/kinsoku_table.tex +++ b/Build/source/texk/web2c/ptexdir/tests/kinsoku_table.tex @@ -1,44 +1,47 @@ -%#!uptex +%#!uptex -ini +\let\dump\relax +\input plain \newcount\fuga\newcount\dflt +\fuga="3300 \iffalse \global\let\prebreakpenalty=\inhibitxspcode - \fuga="30D3 \dflt=3 + \dflt=3 \else - \fuga="3090 \dflt=0 + \dflt=0 \fi \scrollmode \newcount\hoge\hoge="3000 \loop\ifnum\hoge<\fuga \message{\the\hoge}\prebreakpenalty\hoge=2 - \advance\hoge 1\relax \repeat + \advance\hoge 3\relax \repeat -\message{<\the\prebreakpenalty"3001, \the\prebreakpenalty"4000>}% 2, D +\message{<\the\prebreakpenalty"3003, \the\prebreakpenalty"4000>}% 2, D { - \prebreakpenalty"3001=\dflt\relax + \prebreakpenalty"3003=\dflt\relax \global\prebreakpenalty"4000=1\relax% error -\message{<\the\prebreakpenalty"3001, \the\prebreakpenalty"4000>}% D, D +\message{<\the\prebreakpenalty"3003, \the\prebreakpenalty"4000>}% D, D } -\message{<\the\prebreakpenalty"3001, \the\prebreakpenalty"4000>}% 2, D +\message{<\the\prebreakpenalty"3003, \the\prebreakpenalty"4000>}% 2, D { - \global\prebreakpenalty"3001=\dflt\relax + \global\prebreakpenalty"3003=\dflt\relax \prebreakpenalty"4000=1\relax% no error -\message{<\the\prebreakpenalty"3001, \the\prebreakpenalty"4000>}% D, 1 +\message{<\the\prebreakpenalty"3003, \the\prebreakpenalty"4000>}% D, 1 } -\message{<\the\prebreakpenalty"3001, \the\prebreakpenalty"4000>}% D, D +\message{<\the\prebreakpenalty"3003, \the\prebreakpenalty"4000>}% D, D \prebreakpenalty"4000=1\relax% no error -\message{<\the\prebreakpenalty"3001, \the\prebreakpenalty"4000, +\message{<\the\prebreakpenalty"3003, \the\prebreakpenalty"4000, \the\prebreakpenalty"3549>}% D, 1, D \prebreakpenalty"4000=\dflt\relax \prebreakpenalty"3549=1\relax% no error -\message{<\the\prebreakpenalty"3001, \the\prebreakpenalty"4000, +\message{<\the\prebreakpenalty"3003, \the\prebreakpenalty"4000, \the\prebreakpenalty"3549>}% D, D, 1 diff --git a/Build/source/texk/web2c/uptexdir/ChangeLog b/Build/source/texk/web2c/uptexdir/ChangeLog index c1ea8c4ea4e..719bec88973 100644 --- a/Build/source/texk/web2c/uptexdir/ChangeLog +++ b/Build/source/texk/web2c/uptexdir/ChangeLog @@ -71,7 +71,7 @@ 2019-05-06 Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp> * uptex-m.ch: - Make appropreate comparison of U+0100 by \if. + Make appropriate comparison of U+0100 by \if. https://github.com/texjporg/tex-jp-build/issues/68 * tests/test_if.tex: Test case. |