summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHironobu Yamashita <h.y.acetaminophen@gmail.com>2022-02-20 11:11:09 +0000
committerHironobu Yamashita <h.y.acetaminophen@gmail.com>2022-02-20 11:11:09 +0000
commit176e68d07b0c9a121c2b2d675fba4a10ebda8349 (patch)
treecdfd5ffbbc942fb02110cfc28c0b3d1ae8ed0c2b
parent9b080fab6c0e6b01949b0284caf1627437cf2492 (diff)
pbibtex: fix for substring, [u]pbibtex: truncate at least one
git-svn-id: svn://tug.org/texlive/trunk@62095 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Build/source/texk/web2c/ptexdir/ChangeLog8
-rw-r--r--Build/source/texk/web2c/ptexdir/pbibtex.ch61
-rw-r--r--Build/source/texk/web2c/uptexdir/ChangeLog5
-rw-r--r--Build/source/texk/web2c/uptexdir/upbibtex.ch58
4 files changed, 88 insertions, 44 deletions
diff --git a/Build/source/texk/web2c/ptexdir/ChangeLog b/Build/source/texk/web2c/ptexdir/ChangeLog
index 7278c9ae093..1d2cac42dcd 100644
--- a/Build/source/texk/web2c/ptexdir/ChangeLog
+++ b/Build/source/texk/web2c/ptexdir/ChangeLog
@@ -1,3 +1,11 @@
+2022-02-20 Hironobu Yamashita <h.y.acetaminophen@gmail.com>
+
+ * pbibtex.ch: Improve substring$ to truncate at least one
+ character when trying to start counting from the middle
+ byte of the first or last Japanese character.
+ Still version j0.34.
+ https://github.com/texjporg/tex-jp-build/issues/133
+
2022-02-15 Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
* ptex-base.ch: Revised state after a control word which ends
diff --git a/Build/source/texk/web2c/ptexdir/pbibtex.ch b/Build/source/texk/web2c/ptexdir/pbibtex.ch
index d1bcc9a554d..501ff28bc54 100644
--- a/Build/source/texk/web2c/ptexdir/pbibtex.ch
+++ b/Build/source/texk/web2c/ptexdir/pbibtex.ch
@@ -25,8 +25,11 @@
% 2010 Version 0.99d of BibTeX for TeX Live
%
% 2022-02-08 Version 0.34 by H. Yamashita
-% Do not break at white space after Japanese, to preserve spacing
-% within BIB entry spacing to BBL for subsequent pTeX line-end operations
+% * Avoid breaking BBL lines at white space after a Japanese character, to
+% preserve spacing within BIB entry for subsequent pTeX line-end operations.
+% 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.
@x [0] only print chnages
\def\title{\BibTeX\ }
@@ -240,7 +243,7 @@ init_kanji;
parse_arguments;
@z
-% pBibTeX: do not break at |white_space| after Japanese characters
+% pBibTeX: do not break at |white_space| after Japanese characters (2022-02-08 j0.34)
@x "Break that line"
while ((lex_class[out_buf[out_buf_ptr]] <> white_space) and
(out_buf_ptr >= min_print_line)) do
@@ -469,10 +472,20 @@ begin
procedure x_substring;
label exit;
var tps,tpe:pool_pointer; {temporary pointer}
+@!pop_lit2_saved: integer;
begin
@z
-@x Changes for JBibTeX by Shouichi Matsui [438]
+@x
+@<Form the appropriate substring@>=
+begin
+@y
+@<Form the appropriate substring@>=
+begin
+pop_lit2_saved := pop_lit2; {save before negate}
+@z
+
+@x Changes for JBibTeX by Shouichi Matsui [438] + fix (2022-02-20 j0.34)
str_room(sp_end - sp_ptr);
while (sp_ptr < sp_end) do {shift the substring}
begin
@@ -482,27 +495,29 @@ while (sp_ptr < sp_end) do {shift the substring}
@y
{ 2 bytes Kanji code break check }
tps:=str_start[pop_lit3];
-while (tps < sp_ptr) do begin
- if str_pool[tps] > 127
- then tps := tps + 2
- else incr(tps);
-end;
tpe:=tps;
-while (tpe < sp_end) do begin
- if str_pool[tpe] > 127
- then tpe := tpe+2
- else incr(tpe);
-end;
-if tps<>sp_ptr then begin
- if tps>str_start[pop_lit3]
- then decr(sp_ptr)
- else incr(sp_ptr);
-end;
-if tpe<>sp_end then begin
- if tpe<str_start[pop_lit3+1]
- then incr(sp_end)
- else decr(sp_end);
+while tpe < str_start[pop_lit3+1] do begin
+ if str_pool[tpe] > 127 then begin
+ if str_start[pop_lit3+1] < tpe+2 then
+ break;
+ tpe := tpe + 2;
+ end
+ else begin
+ if str_start[pop_lit3+1] < tpe+1 then
+ break;
+ tpe := tpe + 1;
+ end;
+ if tpe<=sp_ptr then
+ tps := tpe;
+ if sp_end<=tpe then break;
end;
+if (pop_lit2_saved > 1) and (tps = str_start[pop_lit3])
+ then tps := tps + 2; {truncate at least one}
+if (pop_lit2_saved < -1) and (tpe = str_start[pop_lit3+1])
+ then tpe := tpe - 2; {truncate at least one}
+if tps > tpe then tpe := tps;
+sp_ptr := tps;
+sp_end := tpe;
str_room(sp_end - sp_ptr);
while (sp_ptr < sp_end) do {shift the substring}
diff --git a/Build/source/texk/web2c/uptexdir/ChangeLog b/Build/source/texk/web2c/uptexdir/ChangeLog
index 41042dbe599..972c74720a7 100644
--- a/Build/source/texk/web2c/uptexdir/ChangeLog
+++ b/Build/source/texk/web2c/uptexdir/ChangeLog
@@ -1,3 +1,8 @@
+2022-02-20 Hironobu Yamashita <h.y.acetaminophen@gmail.com>
+
+ * upbibtex.ch: Adapt to pbibtex.ch.
+ https://github.com/texjporg/tex-jp-build/issues/133
+
2022-02-15 Hironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
* uptex-m.ch: Adapt to ptex-base.ch.
diff --git a/Build/source/texk/web2c/uptexdir/upbibtex.ch b/Build/source/texk/web2c/uptexdir/upbibtex.ch
index d40bcc85dd2..b8b72a47634 100644
--- a/Build/source/texk/web2c/uptexdir/upbibtex.ch
+++ b/Build/source/texk/web2c/uptexdir/upbibtex.ch
@@ -232,42 +232,58 @@ var i:0..last_text_char; {this is the first one declared}
@z
@x
+@!pop_lit2_saved: integer;
+@y
+@!pop_lit2_saved,@!mbl_tpe: integer;
+@z
+
+@x
{ 2 bytes Kanji code break check }
tps:=str_start[pop_lit3];
-while (tps < sp_ptr) do begin
- if str_pool[tps] > 127
- then tps := tps + 2
- else incr(tps);
-end;
tpe:=tps;
-while (tpe < sp_end) do begin
- if str_pool[tpe] > 127
- then tpe := tpe+2
- else incr(tpe);
-end;
-if tps<>sp_ptr then begin
- if tps>str_start[pop_lit3]
- then decr(sp_ptr)
- else incr(sp_ptr);
-end;
-if tpe<>sp_end then begin
- if tpe<str_start[pop_lit3+1]
- then incr(sp_end)
- else decr(sp_end);
+while tpe < str_start[pop_lit3+1] do begin
+ if str_pool[tpe] > 127 then begin
+ if str_start[pop_lit3+1] < tpe+2 then
+ break;
+ tpe := tpe + 2;
+ end
+ else begin
+ if str_start[pop_lit3+1] < tpe+1 then
+ break;
+ tpe := tpe + 1;
+ end;
+ if tpe<=sp_ptr then
+ tps := tpe;
+ if sp_end<=tpe then break;
end;
+if (pop_lit2_saved > 1) and (tps = str_start[pop_lit3])
+ then tps := tps + 2; {truncate at least one}
+if (pop_lit2_saved < -1) and (tpe = str_start[pop_lit3+1])
+ then tpe := tpe - 2; {truncate at least one}
+if tps > tpe then tpe := tps;
+sp_ptr := tps;
+sp_end := tpe;
@y
{ |2..4| bytes Kanji code break check }
tps:=str_start[pop_lit3];
tpe:=tps;
+mbl_tpe:=0;
while tpe < str_start[pop_lit3+1] do begin
- if multibytelen(str_pool[tpe])<0
+ if multibytelen(str_pool[tpe])<0 {just in case}
or (str_start[pop_lit3+1] < tpe+multibytelen(str_pool[tpe])) then
break;
- tpe := tpe + multibytelen(str_pool[tpe]);
+ mbl_tpe := multibytelen(str_pool[tpe]);
+ tpe := tpe + mbl_tpe;
if tpe<=sp_ptr then
tps := tpe;
if sp_end<=tpe then break;
end;
+if (pop_lit2_saved > 1) and (tps = str_start[pop_lit3]) then
+ if multibytelen(str_pool[tps])>=0 then {just in case}
+ tps := tps + multibytelen(str_pool[tps]); {truncate at least one}
+if (pop_lit2_saved < -1) and (tpe = str_start[pop_lit3+1]) then
+ tpe := tpe - mbl_tpe; {truncate at least one}
+if tps > tpe then tpe := tps;
sp_ptr := tps;
sp_end := tpe;
@z