From 5f94645f37aef24b6a3a1952b0724f4782fe99de Mon Sep 17 00:00:00 2001 From: Hironobu Yamashita Date: Wed, 13 Nov 2019 10:14:26 +0000 Subject: e[u]ptex: add \Uchar and \Ucharcat (H. Kitagawa) git-svn-id: svn://tug.org/texlive/trunk@52771 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/eptexdir/ChangeLog | 10 ++ Build/source/texk/web2c/eptexdir/eptex.ech | 4 +- Build/source/texk/web2c/eptexdir/eptex_version.h | 2 +- Build/source/texk/web2c/eptexdir/etex.ch1 | 2 +- Build/source/texk/web2c/eptexdir/pdfutils.ch | 80 ++++++++++++- Build/source/texk/web2c/eptexdir/tests/uchar.tex | 127 +++++++++++++++++++++ Build/source/texk/web2c/euptexdir/ChangeLog | 8 ++ .../texk/web2c/euptexdir/pdfstrcmp-eup-post.ch | 78 +++++++++++++ .../texk/web2c/euptexdir/pdfstrcmp-eup-pre.ch | 8 ++ 9 files changed, 309 insertions(+), 10 deletions(-) create mode 100644 Build/source/texk/web2c/eptexdir/tests/uchar.tex diff --git a/Build/source/texk/web2c/eptexdir/ChangeLog b/Build/source/texk/web2c/eptexdir/ChangeLog index 3b5a30a8f1b..74adf83c2a8 100644 --- a/Build/source/texk/web2c/eptexdir/ChangeLog +++ b/Build/source/texk/web2c/eptexdir/ChangeLog @@ -1,3 +1,13 @@ +2019-11-12 Hironori Kitagawa + + * pdfutils.ch: Add primitives \Uchar and \Ucharcat. + * tests/uchar.tex: Added. + * eptex.ech, eptex_version.h: e-pTeX version 191112. + +2019-10-28 Hironobu Yamashita + + * eptex.ech: Add primitives \current(x)spacingmode. + 2019-09-08 Hironori Kitagawa * eptex.ech: \readline correctly handles Japanese characters. diff --git a/Build/source/texk/web2c/eptexdir/eptex.ech b/Build/source/texk/web2c/eptexdir/eptex.ech index c38831367f6..c9d94603d1d 100644 --- a/Build/source/texk/web2c/eptexdir/eptex.ech +++ b/Build/source/texk/web2c/eptexdir/eptex.ech @@ -26,8 +26,8 @@ @y @d eTeX_version_string=='-2.6' {current \eTeX\ version} @# -@d epTeX_version_string=='-190908' -@d epTeX_version_number==190908 +@d epTeX_version_string=='-191112' +@d epTeX_version_number==191112 @z @x e-pTeX: banner diff --git a/Build/source/texk/web2c/eptexdir/eptex_version.h b/Build/source/texk/web2c/eptexdir/eptex_version.h index c0034c25103..2081950eb22 100644 --- a/Build/source/texk/web2c/eptexdir/eptex_version.h +++ b/Build/source/texk/web2c/eptexdir/eptex_version.h @@ -1 +1 @@ -#define EPTEX_VERSION "190908" +#define EPTEX_VERSION "191112" diff --git a/Build/source/texk/web2c/eptexdir/etex.ch1 b/Build/source/texk/web2c/eptexdir/etex.ch1 index 94415743937..14b10a2925e 100644 --- a/Build/source/texk/web2c/eptexdir/etex.ch1 +++ b/Build/source/texk/web2c/eptexdir/etex.ch1 @@ -109,7 +109,7 @@ disp_node: begin disp:=disp_dimen(p); revdisp:=disp; cur_v:=base_line+disp; end; exit: last_disp:=disp; hpack:=r; @y exit: last_disp:=disp; -if TeXXeT_en then @; +if TeXXeT_en then @; hpack:=r; @z diff --git a/Build/source/texk/web2c/eptexdir/pdfutils.ch b/Build/source/texk/web2c/eptexdir/pdfutils.ch index 88f80935ebc..36e821d1f9a 100644 --- a/Build/source/texk/web2c/eptexdir/pdfutils.ch +++ b/Build/source/texk/web2c/eptexdir/pdfutils.ch @@ -27,6 +27,8 @@ %% \expanded %% %% \ifincsname +%% +%% \Uchar, \Ucharcat @x @* \[8] Packed data. @@ -830,6 +832,33 @@ else if cur_tok=cs_token_flag+frozen_primitive then @ @z +@x \Ucharcat: str_toks_cat +function str_toks(@!b:pool_pointer):pointer; +@y +function str_toks_cat(@!b:pool_pointer;@!cat:small_number):pointer; +@z + +@x \Ucharcat: str_toks_cat + else if t=" " then t:=space_token + else t:=other_token+t; +@y + else if (t=" ")and(cat=0) then t:=space_token + else if (cat=0)or(cat>=kanji) then t:=other_token+t + else if cat=active_char then t:= cs_token_flag + active_base + t + else t:=left_brace_token*cat+t; +@z + +@x \Ucharcat: str_toks_cat +pool_ptr:=b; str_toks:=p; +end; +@y +pool_ptr:=b; str_toks_cat:=p; +end; + +function str_toks(@!b:pool_pointer):pointer; +begin str_toks:=str_toks_cat(b,0); end; +@z + @x @d etex_convert_codes=etex_convert_base+1 {end of \eTeX's command codes} @d job_name_code=etex_convert_codes {command code for \.{\\jobname}} @@ -846,15 +875,18 @@ else if cur_tok=cs_token_flag+frozen_primitive then @d uniform_deviate_code = pdf_first_expand_code+6 {command code for \.{\\pdfuniformdeviate}} @d normal_deviate_code = pdf_first_expand_code+7 {command code for \.{\\pdfnormaldeviate}} @d pdf_convert_codes = pdf_first_expand_code+8 {end of \pdfTeX-like command codes} -@d job_name_code=pdf_convert_codes {command code for \.{\\jobname}} +@d Uchar_convert_code = pdf_convert_codes {command code for \.{\\Uchar}} +@d Ucharcat_convert_code = pdf_convert_codes+1 {command code for \.{\\Ucharcat}} +@d eptex_convert_codes = pdf_convert_codes+2 {end of \epTeX's command codes} +@d job_name_code=eptex_convert_codes {command code for \.{\\jobname}} @z @x primitive("jobname",convert,job_name_code);@/ @y @# -primitive("expanded",convert,expanded_code);@/ -@!@:expanded_}{\.{\\expanded} primitive@> +primitive("expanded",convert,expanded_code);@/ +@!@:expanded_}{\.{\\expanded} primitive@> @# primitive("jobname",convert,job_name_code);@/ @z @@ -872,6 +904,8 @@ primitive("jobname",convert,job_name_code);@/ pdf_file_dump_code: print_esc("pdffiledump"); uniform_deviate_code: print_esc("pdfuniformdeviate"); normal_deviate_code: print_esc("pdfnormaldeviate"); + Uchar_convert_code: print_esc("Uchar"); + Ucharcat_convert_code: print_esc("Ucharcat"); @z @x @@ -885,6 +919,10 @@ we have to create a temporary string that is destroyed immediately after. @d save_cur_string==if str_start[str_ptr]0 then decr(str_ptr) +@ Not all catcode values are allowed by \.{\\Ucharcat}: +@d illegal_Ucharcat_ascii_catcode(#)==(#active_char)or(#=out_param)or(#=ignore) +@d illegal_Ucharcat_wchar_catcode(#)==(#other_kchar) + @p procedure conv_toks; @z @@ -899,15 +937,22 @@ we have to create a temporary string that is destroyed immediately after. @!s: str_number; {first temp string} @!i: integer; @!j: integer; +@!cat:small_number; {desired catcode, or 0 for automatic |spacer|/|other_char| selection} @z @x begin c:=cur_chr; @; @y -begin c:=cur_chr; @; +begin cat:=0; c:=cur_chr; @; u:=0; { will become non-nil if a string is already being built} @z +@x +selector:=old_setting; link(garbage):=str_toks(b); ins_list(link(temp_head)); +@y +selector:=old_setting; link(garbage):=str_toks_cat(b,cat); ins_list(link(temp_head)); +@z + @x eTeX_revision_code: do_nothing; @y @@ -1061,6 +1106,21 @@ pdf_file_dump_code: end; uniform_deviate_code: scan_int; normal_deviate_code: do_nothing; +Uchar_convert_code: scan_char_num; +Ucharcat_convert_code: + begin + scan_ascii_num; + i:=cur_val; + scan_int; + if illegal_Ucharcat_ascii_catcode(cur_val) then + begin print_err("Invalid code ("); print_int(cur_val); +@.Invalid code@> + print("), should be in the ranges 1..4, 6..8, 10..13"); + help1("I'm going to use 12 instead of that illegal code value.");@/ + error; cat:=12; + end else cat:=cur_val; + cur_val:=i; + end; @z @x @@ -1070,6 +1130,10 @@ eTeX_revision_code: print(eTeX_revision); pdf_strcmp_code: print_int(cur_val); uniform_deviate_code: print_int(unif_rand(cur_val)); normal_deviate_code: print_int(norm_rand); +Uchar_convert_code: +if is_char_ascii(cur_val) then print_char(cur_val) else print_kanji(cur_val); +Ucharcat_convert_code: +if cat primitive("pdfresettimer",extension,reset_timer_code);@/ @!@:reset_timer_}{\.{\\pdfresettimer} primitive@> +primitive("Uchar",convert,Uchar_convert_code);@/ +@!@:Uchar_}{\.{\\Uchar} primitive@> +primitive("Ucharcat",convert,Ucharcat_convert_code);@/ +@!@:Ucharcat_}{\.{\\Ucharcat} primitive@> @z @x @@ -1599,7 +1667,7 @@ s:=0; t:=0; bl:=true; while (k='0')and (sop(k)<='9') then begin s:=10*s+sop(k)-'0'; incr(k); @+end else bl:=false; -ifps(1) sop(k)='.' then +ifps(1) sop(k)='.' then begin incr(k); bl:=true; i:=0; dig[0]:=0; while (k='0')and (sop(k)<='9') then @@ -1612,7 +1680,7 @@ ifps(1) sop(k)='.' then if k+4>pool_ptr then if (sop(k)='t')and(sop(k+1)='r')and(sop(k+2)='u')and(sop(k+3)='e') then k:=k+4; -if mag<>1000 then +if mag<>1000 then begin s:=xn_over_d(s,1000,mag); t:=(1000*t+@'200000*remainder) div mag; s:=s+(t div @'200000); t:=t mod @'200000; diff --git a/Build/source/texk/web2c/eptexdir/tests/uchar.tex b/Build/source/texk/web2c/eptexdir/tests/uchar.tex new file mode 100644 index 00000000000..35d29693343 --- /dev/null +++ b/Build/source/texk/web2c/eptexdir/tests/uchar.tex @@ -0,0 +1,127 @@ +% eptex + +% \Uchar +% 0--255:常に欧文文字トークン +% 256以上の,内部コードで許される値:常に和文文字トークン +% \Ucharcat +% in [0,128): 欧文文字トークンを生成. in {1..4, 6..8, 10..13} +% in [128,256) +% e-pTeX の場合:欧文文字トークンを生成. in {1..4, 6..8, 10..13} +% e-upTeX の場合:欧文/和文文字トークンを生成. in {1..4, 6..8, 10..13, 16..19} +% >=256: 和文文字トークンを生成. +% e-pTeX の場合: in {16..18} +% e-upTeX の場合: in {16..19} + + +% e-upTeX: + + +\let\bg={ \let\eg=} +{\catcode`\ =9\relax +\gdef\KCAT{% + \immediate\write17{% + [\expandafter\string\x\space + \expandafter\ifcat\x$ math\space shift\fi + \expandafter\ifcat\x& alignment\fi + \expandafter\ifcat\x^ superscript\fi + \expandafter\ifcat\x_ subscript\fi + \expandafter\ifcat\x\space space\fi + \expandafter\ifcat\x a letter\fi + \expandafter\ifcat\x 1 other\space char\fi + \expandafter\ifcat\x ~ active\fi + \expandafter\ifcat\x 空 kanji\fi + \expandafter\ifcat\x ア kana\fi + \expandafter\ifcat\x { other\space kchar\fi + \ifdefined\ucs + \expandafter\ifcat\x 한 hangul\fi + \fi]}% +}} +\let\sharp=# +\font\x=ec-lmtt10 \x +\scrollmode + +\edef\x{\Uchar`\{}\KCAT +\edef\x{\Uchar`\}}\KCAT +\edef\x{\Uchar`\$}\KCAT +\edef\x{\Uchar`\&}\KCAT +\edef\x{\Uchar`\#}\KCAT +\edef\x{\Uchar`\^}\KCAT +\edef\x{\Uchar`\_}\KCAT +\edef\x{\Uchar`\ }\KCAT +\edef\x{\Uchar`\a}\KCAT +\edef\x{\Uchar`\1}\KCAT +\edef\x{\Uchar`~}\KCAT +\edef\x{\Uchar`漢}\KCAT +\edef\x{\Uchar`あ}\KCAT +\edef\x{\Uchar`)}\KCAT + +\ifdefined\ucs %====== +\immediate\write0{■\string\Uchar\space and \string\kcatcode} +{\kcatcode"03B1=15 \kcatcode"FF=15 +\edef\x{\Uchar"FF}\KCAT%" +\edef\x{\Uchar"03B1}\KCAT%" +} + +{\kcatcode"03B1=17 \kcatcode"FF=17 +\edef\x{\Uchar"FF}\KCAT%" +\edef\x{\Uchar"03B1}\KCAT%" +} +\fi %====== + +\immediate\write0{■\string\Ucharcat.} + +\edef\x{\Ucharcat`\# 0}\KCAT % error "! Invalid code" +\edef\x{\Ucharcat`\# 3}\KCAT +\edef\x{\Ucharcat`\# 4}\KCAT +\edef\x{\Ucharcat`\# 5}\KCAT % error "! Invalid code" +\edef\x{\Ucharcat`\# 7}\KCAT +\edef\x{\Ucharcat`\# 8}\KCAT +\edef\x{\Ucharcat`\# 9}\KCAT % error "! Invalid code" +\edef\x{\Ucharcat`\# 10}\KCAT +\edef\x{\Ucharcat`\# 11}\KCAT +\edef\x{\Ucharcat`\# 12}\KCAT +\edef\x{\unexpanded\expandafter{\Ucharcat`\# 13}} +\message{\expandafter\meaning\unexpanded\expandafter{\x}} % undefined +\edef\x{\Ucharcat`\# 14}\KCAT % error "! Invalid code" +\edef\x{\Ucharcat`\# 15}\KCAT % error "! Invalid code" + +\edef\x{\Ucharcat`\# 16} % error "! Invalid code (16)" +\KCAT + +\ifdefined\ucs %====== +\edef\x{\Ucharcat`漢 3} % error "! Invalid code (3)" +\KCAT + +\edef\x{\Ucharcat`$ 16}\KCAT +\edef\x{\Ucharcat`: 17}\KCAT +\edef\x{\Ucharcat`あ 18}\KCAT +\edef\x{\Ucharcat`漢 19}\KCAT + +{\kcatcode"03B1=15 %" +\edef\x{\Ucharcat"03B1 12}\KCAT%" error "! Invalid code (12)" +\edef\x{\Ucharcat"03B1 17}\KCAT%" +} + +{\kcatcode"03B1=16 %" +\edef\x{\Ucharcat"03B1 12}\KCAT%" error "! Invalid code (12)" +\edef\x{\Ucharcat"03B1 17}\KCAT%" +} + +{\kcatcode"FF=15 %" +\edef\x{\Ucharcat"FF 12}\KCAT%" +\edef\x{\Ucharcat"FF 17}\KCAT%" +} + +{\kcatcode"FF=16 %" +\edef\x{\Ucharcat"FF 12}\KCAT%" +\edef\x{\Ucharcat"FF 17}\KCAT%" +} +\else + +\edef\x{\Ucharcat`漢 3} % error "! Bad character code" in eptex + +\fi % ====== + + +\end + diff --git a/Build/source/texk/web2c/euptexdir/ChangeLog b/Build/source/texk/web2c/euptexdir/ChangeLog index e9f74c7e328..548ffc6c54c 100644 --- a/Build/source/texk/web2c/euptexdir/ChangeLog +++ b/Build/source/texk/web2c/euptexdir/ChangeLog @@ -1,3 +1,11 @@ +2019-11-12 Hironori Kitagawa + + * pdfstrcmp-eup-{pre,post}.ch: Adapt to e-pTeX 191112. + +2019-10-28 Hironobu Yamashita + + * euptex.ch1: Add a primitive \currentcjktoken. + 2019-09-08 Hironori Kitagawa * euptex.ch1: Adapt to changes in eptexdir/. diff --git a/Build/source/texk/web2c/euptexdir/pdfstrcmp-eup-post.ch b/Build/source/texk/web2c/euptexdir/pdfstrcmp-eup-post.ch index 2b154f9a28a..10becd15815 100644 --- a/Build/source/texk/web2c/euptexdir/pdfstrcmp-eup-post.ch +++ b/Build/source/texk/web2c/euptexdir/pdfstrcmp-eup-post.ch @@ -16,6 +16,84 @@ @y @z +@x + check_kcat_code(cc) then + begin if (cc=not_cjk) then cc:=other_kchar; +@y + ((cat>=kanji)or check_kcat_code(cc)) then + begin if cat>=kanji then cc:=cat else if (cc=not_cjk) then cc:=other_kchar; +@z + +@x + else if (t=" ")and(cat=0) then t:=space_token + else if (cat=0)or(cat>=kanji) then t:=other_token+t + else if cat=active_char then t:= cs_token_flag + active_base + t + else t:=left_brace_token*cat+t; +@y + if (t=" ")and(cat=0) then t:=space_token + else if (cat=0)or(cat>=kanji) then t:=other_token+t + else if cat=active_char then t:= cs_token_flag + active_base + t + else t:=left_brace_token*cat+t; +@z + +@x +@d illegal_Ucharcat_wchar_catcode(#)==(#other_kchar) +@y +@d illegal_Ucharcat_wchar_catcode(#)==(#hangul) +@z + +@x +Uchar_convert_code: scan_char_num; +Ucharcat_convert_code: + begin + scan_ascii_num; +@y +Uchar_convert_code: begin scan_char_num; + if not is_char_ascii(cur_val) then + if kcat_code(kcatcodekey(cur_val))=not_cjk then cat:=other_kchar; + end; +Ucharcat_convert_code: + begin + scan_char_num; +@z + +@x + if illegal_Ucharcat_ascii_catcode(cur_val) then + begin print_err("Invalid code ("); print_int(cur_val); +@.Invalid code@> + print("), should be in the ranges 1..4, 6..8, 10..13"); + help1("I'm going to use 12 instead of that illegal code value.");@/ + error; cat:=12; + end else cat:=cur_val; +@y + if i<=@"7F then { no |wchar_token| } + begin if illegal_Ucharcat_ascii_catcode(cur_val) then + begin print_err("Invalid code ("); print_int(cur_val); +@.Invalid code@> + print("), should be in the ranges 1..4, 6..8, 10..13"); + help1("I'm going to use 12 instead of that illegal code value.");@/ + error; cat:=12; + end else cat:=cur_val; + end else if i<=@"FF then + begin if (illegal_Ucharcat_ascii_catcode(cur_val)) + and (illegal_Ucharcat_wchar_catcode(cur_val)) then + begin print_err("Invalid code ("); print_int(cur_val); +@.Invalid code@> + print("), should be in the ranges 1..4, 6..8, 10..13, 16..19"); + help1("I'm going to use 12 instead of that illegal code value.");@/ + error; cat:=12; + end else cat:=cur_val; + end else { |wchar_token| only } + begin if illegal_Ucharcat_wchar_catcode(cur_val) then + begin print_err("Invalid code ("); print_int(cur_val); +@.Invalid code@> + print("), should be in the ranges 16..19"); + help1("I'm going to use 18 instead of that illegal code value.");@/ + error; cat:=other_kchar; + end else cat:=cur_val; + end; +@z + @x procedure print_kanji(@!s:integer); {prints a single character} begin diff --git a/Build/source/texk/web2c/euptexdir/pdfstrcmp-eup-pre.ch b/Build/source/texk/web2c/euptexdir/pdfstrcmp-eup-pre.ch index 80c1a7dd555..b583095744c 100644 --- a/Build/source/texk/web2c/euptexdir/pdfstrcmp-eup-pre.ch +++ b/Build/source/texk/web2c/euptexdir/pdfstrcmp-eup-pre.ch @@ -1,3 +1,11 @@ +@x + if t=" " then t:=space_token + else t:=other_token+t; +@y + else if t=" " then t:=space_token + else t:=other_token+t; +@z + @x procedure print_kanji(@!s:KANJI_code); {prints a single character} begin -- cgit v1.2.3