diff options
-rw-r--r-- | Build/source/texk/web2c/ptexdir/ChangeLog | 24 | ||||
-rw-r--r-- | Build/source/texk/web2c/ptexdir/ptex-base.ch | 76 | ||||
-rw-r--r-- | Build/source/texk/web2c/ptexdir/tests/ptexlineendmode.tex | 60 | ||||
-rw-r--r-- | Build/source/texk/web2c/uptexdir/ChangeLog | 5 | ||||
-rw-r--r-- | Build/source/texk/web2c/uptexdir/uptex-m.ch | 23 |
5 files changed, 171 insertions, 17 deletions
diff --git a/Build/source/texk/web2c/ptexdir/ChangeLog b/Build/source/texk/web2c/ptexdir/ChangeLog index 52c58cfd539..d7fcbc39f07 100644 --- a/Build/source/texk/web2c/ptexdir/ChangeLog +++ b/Build/source/texk/web2c/ptexdir/ChangeLog @@ -1,3 +1,27 @@ +2022-02-15 Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp> + + * ptex-base.ch: Revised state after a control word which ends + with a Japanese character. Starting from pTeX version p4.0.0, + newline char after "a control word ending with a Japanese + character + {}" is ignored. To emulate older behavior, a new + primitive \ptexendlinemode is added. + The new primitive is an internal integer which means: + - When the least significant bit is set, + a blank is generated when the line ends with + "a control word ending with a Japanese character + {}". + - When the second significant bit is set, + a blank is generated when the line ends with + "a Japanese control symbol". + - When the third significant bit is set, + a blank is generated when the line ends with + "a Japanese character (which is not part of a CS) + {}". + By setting \ptexendlinemode to the following values, + old versions of pTeX can be restored: + - p4.0.0 or later : default 0. + - p3.8.2-3.10.0 : similar to 1. + - p3.8.1 or older : similar to 3. + More info: https://github.com/texjporg/tex-jp-build/issues/87 + 2022-02-13 Hironobu Yamashita <h.y.acetaminophen@gmail.com> * ptex-base.ch: \write18 in '^^' format. (Thanks Yukimasa Morimi) diff --git a/Build/source/texk/web2c/ptexdir/ptex-base.ch b/Build/source/texk/web2c/ptexdir/ptex-base.ch index 6474d56cf30..88b050791df 100644 --- a/Build/source/texk/web2c/ptexdir/ptex-base.ch +++ b/Build/source/texk/web2c/ptexdir/ptex-base.ch @@ -1435,7 +1435,8 @@ if n<math_code_base then @d text_baseline_shift_factor_code=57 @d script_baseline_shift_factor_code=58 @d scriptscript_baseline_shift_factor_code=59 -@d tex_int_pars=60 {total number of \TeX's integer parameters} +@d ptex_lineend_code=60 +@d tex_int_pars=61 {total number of \TeX's integer parameters} @z @x [17.236] l.5167 - pTeX: cur_jfam, |jchr_widow_penalty| @@ -1449,6 +1450,7 @@ if n<math_code_base then @d text_baseline_shift_factor==int_par(text_baseline_shift_factor_code) @d script_baseline_shift_factor==int_par(script_baseline_shift_factor_code) @d scriptscript_baseline_shift_factor==int_par(scriptscript_baseline_shift_factor_code) +@d ptex_lineend==int_par(ptex_lineend_code) @z @x [17.237] l.5244 - pTeX: cur_jfam_code, jchr_window_penalty_code @@ -1460,6 +1462,7 @@ jchr_widow_penalty_code:print_esc("jcharwidowpenalty"); text_baseline_shift_factor_code:print_esc("textbaselineshiftfactor"); script_baseline_shift_factor_code:print_esc("scriptbaselineshiftfactor"); scriptscript_baseline_shift_factor_code:print_esc("scriptscriptbaselineshiftfactor"); +ptex_lineend_code:print_esc("ptexlineendmode"); @z @x [17.238] l.5365 - pTeX: cur_jfam_code, jchr_window_penalty_code @@ -1478,6 +1481,8 @@ primitive("scriptbaselineshiftfactor",assign_int,int_base+script_baseline_shift_ @!@:script_baseline_shift_factor}{\.{\\scriptbaselineshiftfactor} primitive@> primitive("scriptscriptbaselineshiftfactor",assign_int,int_base+scriptscript_baseline_shift_factor_code);@/ @!@:scriptscript_baseline_shift_factor}{\.{\\scriptscriptbaselineshiftfactor} primitive@> +primitive("ptexlineendmode",assign_int,int_base+ptex_lineend_code);@/ +@!@:ptex_lineend_mode_}{\.{\\ptexlineendmode} primitive@> @z @x [17.247] l.5490 - pTeX: kinsoku, t_baseline_shift, y_baseline_shift @@ -1691,7 +1696,22 @@ kanji,kana,other_kchar: begin print("kanji character "); 1) |state=mid_line| is the normal state.\cr 2) |state=mid_kanji| is like |mid_line|, and internal KANJI string.\cr 3) |state=skip_blanks| is like |mid_line|, but blanks are ignored.\cr -4) |state=new_line| is the state at the beginning of a line.\cr}}$$ +4) |state=skip_blanks_kanji| is like |mid_kanji|, but blanks are ignored.\cr +5) |state=new_line| is the state at the beginning of a line.\cr}}$$ +@z + +@x +ignored; after this case is processed, the next value of |state| will +be |skip_blanks|. +@y +ignored; after this case is processed, the next value of |state| will +be |skip_blanks|. + +If \.{\\ptexlineendmode} is odd, the |state| become |skip_blanks_kanji| +after a control word which ends with a Japanese character. This is +similar to |skip_blanks|, but the |state| will be |mid_kanji| after +|skip_blanks_kanji+left_brace| and |skip_blanks_kanji+right_brace|, +instead of |mid_line|. @z @x [22.303] l.6736 - pTeX: state mid_kanji @@ -1702,7 +1722,9 @@ kanji,kana,other_kchar: begin print("kanji character "); @d mid_line=1 {|state| code when scanning a line of characters} @d mid_kanji=2+max_char_code {|state| code when scanning a line of characters} @d skip_blanks=3+max_char_code+max_char_code {|state| code when ignoring blanks} -@d new_line=4+max_char_code+max_char_code+max_char_code +@d skip_blanks_kanji=4+max_char_code+max_char_code+max_char_code + {|state| code when ignoring blanks} +@d new_line=5+max_char_code+max_char_code+max_char_code+max_char_code {|state| code at start of line} @z @@ -1846,7 +1868,16 @@ begin switch: if loc<=limit then {current line not yet finished} @x [24.344] l.7535 - pTeX: ASCII-KANJI space handling @d any_state_plus(#) == mid_line+#,skip_blanks+#,new_line+# @y -@d any_state_plus(#) == mid_line+#,mid_kanji+#,skip_blanks+#,new_line+# +@d any_state_plus(#) == + mid_line+#,mid_kanji+#,skip_blanks+#,skip_blanks_kanji+#,new_line+# +@z + +@x +@ @<Cases where character is ignored@>= +any_state_plus(ignore),skip_blanks+spacer,new_line+spacer +@y +@ @<Cases where character is ignored@>= +any_state_plus(ignore),skip_blanks+spacer,skip_blanks_kanji+spacer,new_line+spacer @z @x [24.347] l.7569 - pTeX: scaner @@ -1878,20 +1909,34 @@ mid_kanji+spacer,mid_line+spacer:@<Enter |skip_blanks| state, emit a space@>; mid_line+car_ret:@<Finish line, emit a space@>; mid_kanji+car_ret: if skip_mode then @<Finish line, |goto switch|@> else @<Finish line, emit a space@>; -skip_blanks+car_ret,any_state_plus(comment): +skip_blanks+car_ret,skip_blanks_kanji+car_ret,any_state_plus(comment): @<Finish line, |goto switch|@>; new_line+car_ret:@<Finish line, emit a \.{\\par}@>; -mid_line+left_brace,mid_kanji+left_brace: incr(align_state); +mid_line+left_brace: incr(align_state); +mid_kanji+left_brace: begin incr(align_state); + if ((ptex_lineend div 4) mod 2)=1 then state:=mid_line; + end; skip_blanks+left_brace,new_line+left_brace: begin state:=mid_line; incr(align_state); end; -mid_line+right_brace,mid_kanji+right_brace: decr(align_state); +skip_blanks_kanji+left_brace: begin + state:=mid_kanji; incr(align_state); + end; +mid_line+right_brace: decr(align_state); +mid_kanji+right_brace: begin decr(align_state); + if ((ptex_lineend div 4) mod 2)=1 then state:=mid_line; + end; skip_blanks+right_brace,new_line+right_brace: begin state:=mid_line; decr(align_state); end; -add_delims_to(skip_blanks),add_delims_to(new_line),add_delims_to(mid_kanji): +skip_blanks_kanji+right_brace: begin + state:=mid_kanji; decr(align_state); + end; +add_delims_to(skip_blanks),add_delims_to(skip_blanks_kanji), +add_delims_to(new_line),add_delims_to(mid_kanji): state:=mid_line; -all_jcode(skip_blanks),all_jcode(new_line),all_jcode(mid_line): +all_jcode(skip_blanks),all_jcode(skip_blanks_kanji),all_jcode(new_line), +all_jcode(mid_line): state:=mid_kanji; @ @<Global...@>= @@ -1933,9 +1978,14 @@ else begin k:=loc; cur_chr:=buffer[k]; incr(k); end else cat:=cat_code(cur_chr); start_cs: - if (cat=letter)or(cat=kanji)or(cat=kana) then state:=skip_blanks + if cat=letter then state:=skip_blanks + else if (cat=kanji)or(cat=kana) then + begin if (ptex_lineend mod 2)=0 then state:=skip_blanks_kanji + else state:=skip_blanks end else if cat=spacer then state:=skip_blanks - else if cat=other_kchar then state:=mid_kanji + else if cat=other_kchar then + begin if ((ptex_lineend div 2) mod 2)=0 then state:=mid_kanji + else state:=mid_line end else state:=mid_line; if cat=other_kchar then begin cur_cs:=id_lookup(loc,k-loc); loc:=k; goto found; @@ -2022,6 +2072,9 @@ begin repeat cur_chr:=buffer[k]; incr(k); for l:=k-1 to k-2+multistrlen(ustringcast(buffer), limit+1, k-1) do buffer2[l]:=1; incr(k); + if (cat=kanji)or(cat=kana) then + begin if (ptex_lineend mod 2)=0 then state:=skip_blanks_kanji + else state:=skip_blanks end; end else cat:=cat_code(cur_chr); while (buffer[k]=cur_chr)and(cat=sup_mark)and(k<limit) do @@ -2046,6 +2099,7 @@ begin repeat cur_chr:=buffer[k]; incr(k); end; end; end; + if cat=letter then state:=skip_blanks; until not((cat=letter)or(cat=kanji)or(cat=kana))or(k>limit); {@@<If an expanded...@@>;} if not((cat=letter)or(cat=kanji)or(cat=kana)) then decr(k); diff --git a/Build/source/texk/web2c/ptexdir/tests/ptexlineendmode.tex b/Build/source/texk/web2c/ptexdir/tests/ptexlineendmode.tex new file mode 100644 index 00000000000..5dce40d2e12 --- /dev/null +++ b/Build/source/texk/web2c/ptexdir/tests/ptexlineendmode.tex @@ -0,0 +1,60 @@ +\font\fn=ec-lmr10\fn\catcode`\^^9f=11 +\def\◆{◇}\def\漢{◇}\def\^^9f{S} + +\ptexlineendmode=0 % p4.0.0標準 +{{{\the\ptexlineendmode ◆} +◆\◆ +あ\◆} +い◆\漢} +◆\漢 漢字\^^9f a\quad p4.0.0以降 + +\ptexlineendmode=1 % p3.8.2標準 +{{{\the\ptexlineendmode ◆} +◆\◆ +あ\◆} +い◆\漢} +◆\漢 漢字\^^9f a\quad p3.8.2以降 + +\ptexlineendmode=2 +{{{\the\ptexlineendmode ◆} +◆\◆ +あ\◆} +い◆\漢} +◆\漢 漢字\^^9f a + +\ptexlineendmode=3 +{{{\the\ptexlineendmode ◆} +◆\◆ +あ\◆} +い◆\漢} +◆\漢 漢字\^^9f a\quad p3.8.1以前 + +\ptexlineendmode=4 +{{{\the\ptexlineendmode ◆} +◆\◆ +あ\◆} +い◆\漢} +◆\漢 漢字\^^9f a + +\ptexlineendmode=5 +{{{\the\ptexlineendmode ◆} +◆\◆ +あ\◆} +い◆\漢} +◆\漢 漢字\^^9f a + +\ptexlineendmode=6 +{{{\the\ptexlineendmode ◆} +◆\◆ +あ\◆} +い◆\漢} +◆\漢 漢字\^^9f a + +\ptexlineendmode=7 +{{{\the\ptexlineendmode ◆} +◆\◆ +あ\◆} +い◆\漢} +◆\漢 漢字\^^9f a + +\bye diff --git a/Build/source/texk/web2c/uptexdir/ChangeLog b/Build/source/texk/web2c/uptexdir/ChangeLog index 40ed817d46b..41042dbe599 100644 --- a/Build/source/texk/web2c/uptexdir/ChangeLog +++ b/Build/source/texk/web2c/uptexdir/ChangeLog @@ -1,3 +1,8 @@ +2022-02-15 Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp> + + * uptex-m.ch: Adapt to ptex-base.ch. + More info: https://github.com/texjporg/tex-jp-build/issues/87 + 2022-02-13 Hironobu Yamashita <h.y.acetaminophen@gmail.com> * upbibtex.ch: Adapt to pbibtex.ch (version number). diff --git a/Build/source/texk/web2c/uptexdir/uptex-m.ch b/Build/source/texk/web2c/uptexdir/uptex-m.ch index c12721adfb7..b153c33328e 100644 --- a/Build/source/texk/web2c/uptexdir/uptex-m.ch +++ b/Build/source/texk/web2c/uptexdir/uptex-m.ch @@ -421,12 +421,15 @@ if ((kcp mod @'10)>0)and(nrestmultichr(kcp)>0) then p:=p-(kcp mod @'10); @z @x -all_jcode(skip_blanks),all_jcode(new_line),all_jcode(mid_line): +all_jcode(skip_blanks),all_jcode(skip_blanks_kanji),all_jcode(new_line), +all_jcode(mid_line): state:=mid_kanji; @y -all_jcode(skip_blanks),all_jcode(new_line),all_jcode(mid_line): +all_jcode(skip_blanks),all_jcode(skip_blanks_kanji),all_jcode(new_line), +all_jcode(mid_line): state:=mid_kanji; -hangul_code(skip_blanks),hangul_code(new_line),hangul_code(mid_kanji): +hangul_code(skip_blanks),hangul_code(skip_blanks_kanji),hangul_code(new_line), +hangul_code(mid_kanji): state:=mid_line; @z @@ -440,7 +443,7 @@ else begin k:=loc; cur_chr:=buffer[k]; incr(k); end else cat:=cat_code(cur_chr); start_cs: - if (cat=letter)or(cat=kanji)or(cat=kana) then state:=skip_blanks + if cat=letter then state:=skip_blanks @y else begin k:=loc; cur_chr:=fromBUFF(ustringcast(buffer), limit+1, k); @@ -456,7 +459,7 @@ else begin k:=loc; incr(k); end; start_cs: - if (cat=letter)or(cat=kanji)or(cat=kana)or(cat=hangul) then state:=skip_blanks + if (cat=letter)or(cat=hangul) then state:=skip_blanks @z @x @@ -478,6 +481,9 @@ begin repeat cur_chr:=buffer[k]; incr(k); for l:=k-1 to k-2+multistrlen(ustringcast(buffer), limit+1, k-1) do buffer2[l]:=1; incr(k); + if (cat=kanji)or(cat=kana) then + begin if (ptex_lineend mod 2)=0 then state:=skip_blanks_kanji + else state:=skip_blanks end; end else cat:=cat_code(cur_chr); @y @@ -488,7 +494,12 @@ begin repeat if (cat=not_cjk) then cat:=other_kchar; for l:=k to k-1+multistrlen(ustringcast(buffer), limit+1, k) do buffer2[l]:=1; - k:=k+multistrlen(ustringcast(buffer), limit+1, k) end + k:=k+multistrlen(ustringcast(buffer), limit+1, k); + if (cat=kanji)or(cat=kana) then + begin if (ptex_lineend mod 2)=0 then state:=skip_blanks_kanji + else state:=skip_blanks end + else if cat=hangul then state:=skip_blanks; + end else begin {not multi-byte char} cur_chr:=buffer[k]; cat:=cat_code(cur_chr); |