From 622b49804740c998dab033ab7dfaca46062d9944 Mon Sep 17 00:00:00 2001 From: Takuji Tanaka Date: Sun, 15 May 2022 11:23:40 +0000 Subject: (u)pbibtex: j0.35, accept multibyte chars by int.to.chr$ & chr.to.int$ git-svn-id: svn://tug.org/texlive/trunk@63305 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/ptexdir/ChangeLog | 7 +++ Build/source/texk/web2c/ptexdir/pbibtex.ch | 88 ++++++++++++++++++++++++---- Build/source/texk/web2c/ptexdir/ptex.defines | 1 + Build/source/texk/web2c/uptexdir/ChangeLog | 6 ++ Build/source/texk/web2c/uptexdir/upbibtex.ch | 37 ++++++++++-- 5 files changed, 123 insertions(+), 16 deletions(-) (limited to 'Build/source/texk') diff --git a/Build/source/texk/web2c/ptexdir/ChangeLog b/Build/source/texk/web2c/ptexdir/ChangeLog index 35f41474ee0..8d32404f757 100644 --- a/Build/source/texk/web2c/ptexdir/ChangeLog +++ b/Build/source/texk/web2c/ptexdir/ChangeLog @@ -1,3 +1,10 @@ +2022-05-15 TANAKA Takuji + + * pbibtex.ch, ptex.defines: + Accept multibyte characters by int.to.chr$ and chr.to.int$, i.e. + chr is corresponding to one single character multibyte string. + Bump version to j0.35 + 2022-05-06 TANAKA Takuji * pbibtex.test: Update a test. diff --git a/Build/source/texk/web2c/ptexdir/pbibtex.ch b/Build/source/texk/web2c/ptexdir/pbibtex.ch index 501ff28bc54..8b5f2077698 100644 --- a/Build/source/texk/web2c/ptexdir/pbibtex.ch +++ b/Build/source/texk/web2c/ptexdir/pbibtex.ch @@ -30,12 +30,14 @@ % 2022-02-20 Still version 0.34 by H. Yamashita (-> TL'22 version) % * Improve substring$ to truncate at least one character when trying to % start counting from the middle byte of the first or last Japanese character. +% 2022-05-15 Version 0.35 by Takuji Tanaka (-> TL'23 version) +% * Accept multibyte characters by int.to.chr$ and chr.to.int$. @x [0] only print chnages \def\title{\BibTeX\ } @y \let\maybe=\iffalse -\def\title{J\BibTeX\ 0.34 Changes for C Version \BibTeX\ } +\def\title{J\BibTeX\ 0.35 Changes for C Version \BibTeX\ } @z @x @@ -45,7 +47,7 @@ @y \def\titlepage{F} \centerline{\:\titlefont The {\:\ttitlefont J\BibTeX} preprocessor} - \vskip 15pt \centerline{(Version 0.99d-j0.34---\today)} \vfill} + \vskip 15pt \centerline{(Version 0.99d-j0.35---\today)} \vfill} @z %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -56,7 +58,7 @@ @d banner=='This is BibTeX, Version 0.99d' {printed when the program starts} @y @d my_name=='pbibtex' -@d banner=='This is pBibTeX, Version 0.99d-j0.34' +@d banner=='This is pBibTeX, Version 0.99d-j0.35' {printed when the program starts} @z @@ -339,7 +341,7 @@ case (str_pool[sp_ptr]) of @ @z -@x Changes for JBibTeX by Shouichi Matsui [377] +@x x_chr_to_int else if (length(pop_lit1) <> 1) then begin print ('"'); @@ -347,15 +349,25 @@ else if (length(pop_lit1) <> 1) then bst_ex_warn ('" isn''t a single character'); push_lit_stk (0, stk_int); end +else + push_lit_stk (str_pool[str_start[pop_lit1]], stk_int); + {push the (|ASCII_code|) integer} @y -else if (length(pop_lit1) <> 1) then - if(str_pool[str_start[pop_lit1]]>127) then { a KANJI char is 2byte long } +else if (length(pop_lit1) = multibytelen(str_pool[str_start[pop_lit1]])) then + begin + if (length(pop_lit1) = 1) then push_lit_stk(str_pool[str_start[pop_lit1]],stk_int) - else begin - print ('"'); - print_pool_str (pop_lit1); - bst_ex_warn ('" isn''t a single character'); - push_lit_stk (0, stk_int); + {push the (|ASCII_code|) integer} + else + push_lit_stk(toDVI(fromBUFF(str_pool, str_start[pop_lit1]+2, str_start[pop_lit1])),stk_int) + { a KANJI char is 2byte long } + end +else + begin + print ('"'); + print_pool_str (pop_lit1); + bst_ex_warn ('" isn''t a single character'); + push_lit_stk (0, stk_int); end @z @@ -462,6 +474,60 @@ end; else if ((name_buf[name_bf_ptr] = left_brace) and @z +@x x_int_to_chr +procedure x_int_to_chr; +begin +pop_lit_stk (pop_lit1,pop_typ1); +if (pop_typ1 <> stk_int) then + begin + print_wrong_stk_lit (pop_lit1,pop_typ1,stk_int); + push_lit_stk (s_null, stk_str); + end +else if ((pop_lit1 < 0) or (pop_lit1 > 127)) then + begin + bst_ex_warn (pop_lit1:0,' isn''t valid ASCII'); + push_lit_stk (s_null, stk_str); + end +else + begin + str_room(1); + append_char (pop_lit1); + push_lit_stk (make_string, stk_str); + end; +end; +@y +procedure x_int_to_chr; +var k:integer; +begin +pop_lit_stk (pop_lit1,pop_typ1); +if (pop_typ1 <> stk_int) then + begin + print_wrong_stk_lit (pop_lit1,pop_typ1,stk_int); + push_lit_stk (s_null, stk_str); + end +else begin +k:=pop_lit1; +if (pop_lit1 > 127) then k:=fromDVI(pop_lit1); +if ((pop_lit1 < 0) or ((pop_lit1 > 127) and (k = 0))) then + begin + bst_ex_warn (pop_lit1:0,' isn''t valid character code'); + push_lit_stk (s_null, stk_str); + end +else + begin + str_room(2); + if (pop_lit1>127) then begin + append_char (Hi(k)); + append_char (Lo(k)); + end + else + append_char (pop_lit1); + push_lit_stk (make_string, stk_str); + end; +end; +end; +@z + @x Changes for JBibTeX by Shouichi Matsui [437] @<|execute_fn|({\.{substring\$}})@>= procedure x_substring; diff --git a/Build/source/texk/web2c/ptexdir/ptex.defines b/Build/source/texk/web2c/ptexdir/ptex.defines index 7e3103f930b..63801c1930d 100644 --- a/Build/source/texk/web2c/ptexdir/ptex.defines +++ b/Build/source/texk/web2c/ptexdir/ptex.defines @@ -11,6 +11,7 @@ @define function multistrlen (); @define function multistrlenshort (); @define function multistrlenfilename (); +@define function multibytelen (); @define function fromBUFF (); @define function fromBUFFshort (); @define function toBUFF (); diff --git a/Build/source/texk/web2c/uptexdir/ChangeLog b/Build/source/texk/web2c/uptexdir/ChangeLog index 6957eab5094..e6e481b8bfb 100644 --- a/Build/source/texk/web2c/uptexdir/ChangeLog +++ b/Build/source/texk/web2c/uptexdir/ChangeLog @@ -1,3 +1,9 @@ +2022-05-15 TANAKA Takuji + + * upbibtex.ch: + Accept multibyte characters by int.to.chr$ and chr.to.int$, i.e. + chr is corresponding to one single character multibyte string. + 2022-05-07 TANAKA Takuji * upbibtex.ch: diff --git a/Build/source/texk/web2c/uptexdir/upbibtex.ch b/Build/source/texk/web2c/uptexdir/upbibtex.ch index dcecabde131..4493d9f32c7 100644 --- a/Build/source/texk/web2c/uptexdir/upbibtex.ch +++ b/Build/source/texk/web2c/uptexdir/upbibtex.ch @@ -1,9 +1,9 @@ @x @d my_name=='pbibtex' -@d banner=='This is pBibTeX, Version 0.99d-j0.34' +@d banner=='This is pBibTeX, Version 0.99d-j0.35' @y @d my_name=='upbibtex' -@d banner=='This is upBibTeX, Version 0.99d-j0.34-u1.28' +@d banner=='This is upBibTeX, Version 0.99d-j0.35-u1.28' @z @x @@ -258,10 +258,12 @@ var i:0..last_text_char; {this is the first one declared} end; @z -@x - if(str_pool[str_start[pop_lit1]]>127) then { a KANJI char is 2byte long } +@x x_chr_to_int + push_lit_stk(toDVI(fromBUFF(str_pool, str_start[pop_lit1]+2, str_start[pop_lit1])),stk_int) + { a KANJI char is 2byte long } @y - if(str_pool[str_start[pop_lit1]]>127) then { a KANJI char is |2..4|byte long } + push_lit_stk(toDVI(fromBUFF(str_pool, str_start[pop_lit1]+length(pop_lit1), str_start[pop_lit1])),stk_int) + { a KANJI char is |2..4|byte long } @z @x @@ -357,6 +359,31 @@ var i:0..last_text_char; {this is the first one declared} name_bf_ptr := name_bf_ptr + multibytelen(name_buf[name_bf_ptr])-1; @z +@x x_int_to_chr + str_room(2); + if (pop_lit1>127) then begin + append_char (Hi(k)); + append_char (Lo(k)); + end + else + append_char (pop_lit1); + push_lit_stk (make_string, stk_str); + end; +@y + str_room(4); + k:=toBUFF(k); + if (BYTE1(k)>0) then + append_char (BYTE1(k)); + if (BYTE2(k)>0) then + append_char (BYTE2(k)); + if (BYTE3(k)>0) then + append_char (BYTE3(k)); + { always } + append_char (BYTE4(k)); + push_lit_stk (make_string, stk_str); + end; +@z + @x @!pop_lit2_saved: integer; @y -- cgit v1.2.3