| 1 |
% $Id: uptex-m.ch 77176 2025-12-26 09:08:28Z takuji $ |
| 2 |
% This is a change file for upTeX u2.00 |
| 3 |
% By Takuji Tanaka. |
| 4 |
% |
| 5 |
% (02/26/2007) TTK upTeX u0.01 |
| 6 |
% (03/18/2007) TTK upTeX u0.03 |
| 7 |
% (04/08/2007) TTK upTeX u0.05 |
| 8 |
% (04/15/2007) TTK upTeX u0.06 |
| 9 |
% (05/13/2007) TTK upTeX u0.07 |
| 10 |
% (05/28/2007) TTK upTeX u0.08 |
| 11 |
% (06/16/2007) TTK upTeX u0.09 |
| 12 |
% (07/28/2007) TTK upTeX u0.10 |
| 13 |
% (08/07/2007) TTK upTeX u0.11 |
| 14 |
% (08/25/2007) TTK upTeX u0.12 |
| 15 |
% (09/15/2007) TTK upTeX u0.13 |
| 16 |
% (09/25/2007) TTK upTeX u0.14 |
| 17 |
% (10/18/2007) TTK upTeX u0.15 |
| 18 |
% (11/10/2007) TTK upTeX u0.16 |
| 19 |
% (11/13/2007) TTK upTeX u0.17 |
| 20 |
% (12/08/2007) TTK upTeX u0.18 |
| 21 |
% (12/26/2007) TTK upTeX u0.19 |
| 22 |
% (01/12/2008) TTK upTeX u0.20 |
| 23 |
% (03/13/2008) TTK upTeX u0.21 |
| 24 |
% (08/03/2008) TTK upTeX u0.22 |
| 25 |
% (09/04/2008) TTK upTeX u0.23 |
| 26 |
% (10/18/2008) TTK upTeX u0.24 |
| 27 |
% (12/13/2008) TTK upTeX u0.25 |
| 28 |
% (02/21/2009) TTK upTeX u0.26 |
| 29 |
% (03/12/2009) TTK upTeX u0.27 |
| 30 |
% (08/23/2009) TTK upTeX u0.28 |
| 31 |
% (01/31/2010) TTK upTeX u0.29 |
| 32 |
% (04/10/2010) TTK upTeX u0.30 |
| 33 |
% (01/15/2012) TTK upTeX u1.00 |
| 34 |
% (04/29/2012) TTK upTeX u1.10 |
| 35 |
% (08/13/2012) TTK upTeX u1.11 |
| 36 |
% (12/29/2014) TTK upTeX u1.20 |
| 37 |
% (02/20/2016) TTK upTeX u1.21 |
| 38 |
% (01/15/2017) TTK upTeX u1.22 |
| 39 |
% (04/09/2017) TTK Hironori Kitagawa fixed a bug in \endlinechar. |
| 40 |
% (2018-01-21) HK Added \uptexversion primitive and co. |
| 41 |
% (2018-02-24) TTK upTeX u1.23 |
| 42 |
% (2019-02-23) TTK upTeX u1.24 |
| 43 |
% (2019-05-06) HK Hironori Kitagawa fixed a bug in \if. |
| 44 |
% (2019-05-06) TTK upTeX u1.25 |
| 45 |
% (2020-02-22) TTK upTeX u1.26 |
| 46 |
% (2020-10-25) TTK upTeX u1.27 |
| 47 |
% (2022-01-23) TTK upTeX u1.28 |
| 48 |
% (2022-07-23) TTK upTeX u1.29 |
| 49 |
% (2022-12-09) HK Hironori Kitagawa fixed a bug in \char, \kchar. |
| 50 |
% (2023-09-16) TTK upTeX u1.30 |
| 51 |
% (2024-09-30) TTK upTeX u1.35 |
| 52 |
% (2024-10-20) TTK upTeX u2.00 |
| 53 |
% (2025-01-02) TTK Accept extended upTeX internal encoding also in pTeX-compatible EUC/SJIS mode. |
| 54 |
% (2025-04-05) TTK upTeX u2.01 |
| 55 |
% (2025-12-26) TTK upTeX u2.02 |
| 56 |
|
| 57 |
@x |
| 58 |
\def\pTeX{p\kern-.15em\TeX} |
| 59 |
@y |
| 60 |
\def\pTeX{p\kern-.15em\TeX} |
| 61 |
\def\upTeX{u\pTeX} |
| 62 |
@z |
| 63 |
|
| 64 |
@x upTeX: banner |
| 65 |
{printed when \pTeX\ starts} |
| 66 |
@y |
| 67 |
{printed when \pTeX\ starts} |
| 68 |
@# |
| 69 |
@d upTeX_version=2 |
| 70 |
@d upTeX_revision==".02" |
| 71 |
@d upTeX_version_string=='-u2.02' {current \upTeX\ version} |
| 72 |
@# |
| 73 |
@d upTeX_banner=='This is upTeX, Version 3.141592653',pTeX_version_string,upTeX_version_string |
| 74 |
@d upTeX_banner_k==upTeX_banner |
| 75 |
{printed when \upTeX\ starts} |
| 76 |
@z |
| 77 |
|
| 78 |
@x upTeX: banner |
| 79 |
@d banner==pTeX_banner |
| 80 |
@d banner_k==pTeX_banner_k |
| 81 |
@y |
| 82 |
@d banner==upTeX_banner |
| 83 |
@d banner_k==upTeX_banner_k |
| 84 |
@z |
| 85 |
|
| 86 |
@x |
| 87 |
@!KANJI_code=0..65535; {sixteen-bit numbers} |
| 88 |
@y |
| 89 |
@!KANJI_code=0..@"FFFFFF; {0..0x10FFFF: Unicode, 0x110000..0xFFFFFF: special} |
| 90 |
@z |
| 91 |
|
| 92 |
@x |
| 93 |
@!trick_buf2:array[0..ssup_error_line] of 0..2; {pTeX: buffer for KANJI} |
| 94 |
@!kcode_pos: 0..2; {pTeX: denotes whether first byte or second byte of KANJI} |
| 95 |
@y |
| 96 |
@!trick_buf2:array[0..ssup_error_line] of 0..@'24; {pTeX: buffer for KANJI} |
| 97 |
@!kcode_pos: 0..@'24; {pTeX: denotes whether first byte or second byte of KANJI |
| 98 |
1..2:2byte-char, 11..13:3byte-char, 21..24:4byte-char} |
| 99 |
@!kcp: 0..@'24; {temporary |kcode_pos|} |
| 100 |
@z |
| 101 |
|
| 102 |
@x |
| 103 |
procedure print_ln; {prints an end-of-line} |
| 104 |
@y |
| 105 |
procedure print_ln; {prints an end-of-line} |
| 106 |
var @!ii: integer; |
| 107 |
@z |
| 108 |
|
| 109 |
@x |
| 110 |
if kcode_pos=1 then begin wterm(' '); wlog(' '); end; |
| 111 |
@y |
| 112 |
if nrestmultichr(kcode_pos)>0 then |
| 113 |
for ii:=0 to nrestmultichr(kcode_pos)-1 do |
| 114 |
begin wterm(' '); wlog(' '); end; |
| 115 |
@z |
| 116 |
|
| 117 |
@x |
| 118 |
log_only: begin if kcode_pos=1 then wlog(' '); |
| 119 |
@y |
| 120 |
log_only: begin |
| 121 |
if nrestmultichr(kcode_pos)>0 then |
| 122 |
for ii:=0 to nrestmultichr(kcode_pos)-1 do wlog(' '); |
| 123 |
@z |
| 124 |
|
| 125 |
@x |
| 126 |
term_only: begin if kcode_pos=1 then wterm(' '); |
| 127 |
@y |
| 128 |
term_only: begin |
| 129 |
if nrestmultichr(kcode_pos)>0 then |
| 130 |
for ii:=0 to nrestmultichr(kcode_pos)-1 do wterm(' '); |
| 131 |
@z |
| 132 |
|
| 133 |
@x |
| 134 |
else if kcode_pos=1 then kcode_pos:=2 |
| 135 |
@y |
| 136 |
else if (kcode_pos=1)or((kcode_pos>=@'11)and(kcode_pos<=@'12)) |
| 137 |
or((kcode_pos>=@'21)and(kcode_pos<=@'23)) then incr(kcode_pos) |
| 138 |
@z |
| 139 |
|
| 140 |
@x |
| 141 |
begin kcode_pos:=1; |
| 142 |
@y |
| 143 |
begin |
| 144 |
if (ismultichr(4,1,xchr[s])) then kcode_pos:=@'21 |
| 145 |
else if (ismultichr(3,1,xchr[s])) then kcode_pos:=@'11 |
| 146 |
else kcode_pos:=1; |
| 147 |
@z |
| 148 |
|
| 149 |
@x |
| 150 |
if file_offset>=max_print_line-1 then |
| 151 |
@y |
| 152 |
if file_offset>=max_print_line-nrestmultichr(kcode_pos) then |
| 153 |
@z |
| 154 |
|
| 155 |
@x |
| 156 |
if term_offset>=max_print_line-1 then |
| 157 |
@y |
| 158 |
if term_offset>=max_print_line-nrestmultichr(kcode_pos) then |
| 159 |
@z |
| 160 |
|
| 161 |
@x |
| 162 |
@d min_quarterword=0 {smallest allowable value in a |quarterword|} |
| 163 |
@d max_quarterword=@"FFFF {largest allowable value in a |quarterword|} |
| 164 |
@d min_halfword==-@"FFFFFFF {smallest allowable value in a |halfword|} |
| 165 |
@d max_halfword==@"FFFFFFF {largest allowable value in a |halfword|} |
| 166 |
@d max_cjk_val=@"10000 |
| 167 |
@y |
| 168 |
@d min_quarterword=0 {smallest allowable value in a |quarterword|} |
| 169 |
@d max_quarterword=@"FFFF {largest allowable value in a |quarterword|} |
| 170 |
@d min_halfword=-@"3FFFFFFF {smallest allowable value in a |halfword|} |
| 171 |
@d max_halfword=@"3FFFFFFF {largest allowable value in a |halfword|} |
| 172 |
@d max_cjk_val=@"1000000 {to separate wchar and kcatcode} |
| 173 |
@d max_ivs_val=@"4400000 {to separate wchar with ivs and kcatcode} |
| 174 |
@d max_ucs_val=@"110000 {largest Unicode Scalar Value} |
| 175 |
@d max_latin_val=@"2E80 |
| 176 |
@z |
| 177 |
|
| 178 |
@x |
| 179 |
@p function new_ligature(@!f:internal_font_number; @!c:quarterword; |
| 180 |
@!q:pointer):pointer; |
| 181 |
var p:pointer; {the new node} |
| 182 |
begin p:=get_node(small_node_size); type(p):=ligature_node; |
| 183 |
font(lig_char(p)):=f; character(lig_char(p)):=c; lig_ptr(p):=q; |
| 184 |
subtype(p):=0; new_ligature:=p; |
| 185 |
end; |
| 186 |
@y |
| 187 |
@p function new_ligature(@!f:internal_font_number; @!c:quarterword; |
| 188 |
@!q:pointer):pointer; |
| 189 |
var p:pointer; {the new node} |
| 190 |
begin p:=get_node(small_node_size); |
| 191 |
c:=ptenc8bitcodetoucs(font_enc[f],c); |
| 192 |
type(p):=ligature_node; |
| 193 |
font(lig_char(p)):=f; character(lig_char(p)):=c; lig_ptr(p):=q; |
| 194 |
subtype(p):=0; new_ligature:=p; |
| 195 |
end; |
| 196 |
@z |
| 197 |
|
| 198 |
@x |
| 199 |
function new_lig_item(@!c:quarterword):pointer; |
| 200 |
var p:pointer; {the new node} |
| 201 |
begin p:=get_node(small_node_size); character(p):=c; lig_ptr(p):=null; |
| 202 |
@y |
| 203 |
function new_lig_item(@!c:quarterword):pointer; |
| 204 |
var p:pointer; {the new node} |
| 205 |
begin p:=get_node(small_node_size); |
| 206 |
c:=ptenc8bitcodetoucs(font_enc[f],c); |
| 207 |
character(p):=c; lig_ptr(p):=null; |
| 208 |
@z |
| 209 |
|
| 210 |
@x |
| 211 |
if font_dir[font(p)]<>dir_default then |
| 212 |
begin p:=link(p); print_kanji(info(p)); |
| 213 |
end |
| 214 |
else print_ASCII(qo(character(p))); |
| 215 |
@y |
| 216 |
if font_dir[font(p)]<>dir_default then |
| 217 |
begin p:=link(p); print_kanji(info(p)); |
| 218 |
end |
| 219 |
else if check_echar_range(qo(character(p)))=1 then |
| 220 |
print_kanji(qo(character(p))) |
| 221 |
else print_ASCII(qo(character(p))); |
| 222 |
@z |
| 223 |
|
| 224 |
@x |
| 225 |
print_char(" "); |
| 226 |
if font_dir[font(p)]<>dir_default then |
| 227 |
begin p:=link(p); print_kanji(info(p)); |
| 228 |
end |
| 229 |
else print_ASCII(qo(character(p))); |
| 230 |
@y |
| 231 |
print_char(" "); |
| 232 |
if font_dir[font(p)]<>dir_default then |
| 233 |
begin p:=link(p); print_kanji(info(p)); |
| 234 |
end |
| 235 |
else if check_echar_range(qo(character(p)))=1 then |
| 236 |
print_kanji(qo(character(p))) |
| 237 |
else print_ASCII(qo(character(p))); |
| 238 |
@z |
| 239 |
|
| 240 |
@x |
| 241 |
@d kanji=16 {kanji} |
| 242 |
@d kana=17 {hiragana, katakana, alphabet} |
| 243 |
@d other_kchar=18 {kanji codes} |
| 244 |
@d max_char_code=18 {largest catcode for individual characters} |
| 245 |
@y |
| 246 |
@d latin_ucs=14 {is not cjk characters in ucs code} |
| 247 |
@d not_cjk=15 {is not cjk characters} |
| 248 |
@d kanji=16 {kanji} |
| 249 |
@d kana=17 {hiragana, katakana, alphabet} |
| 250 |
@d other_kchar=18 {cjk symbol codes} |
| 251 |
@d hangul=19 {hangul codes} |
| 252 |
@d modifier=20 {modifier codes} |
| 253 |
@d kanji_ivs=23 {kanji with ivs codes} |
| 254 |
@d max_char_code=20 {largest catcode for individual characters} |
| 255 |
@z |
| 256 |
|
| 257 |
@x |
| 258 |
@d char_num=max_char_code+1 {character specified numerically ( \.{\\char} )} |
| 259 |
@d math_char_num=char_num+1 {explicit math code ( \.{\\mathchar} )} |
| 260 |
@y |
| 261 |
@d char_num=max_char_code+1 {character specified numerically ( \.{\\char} )} |
| 262 |
@d kchar_num=char_num+1 {cjk character specified numerically ( \.{\\kchar} )} |
| 263 |
@d math_char_num=kchar_num+1 {explicit math code ( \.{\\mathchar} )} |
| 264 |
@z |
| 265 |
|
| 266 |
@x |
| 267 |
@d math_given=char_given+1 {math code defined by \.{\\mathchardef}} |
| 268 |
@y |
| 269 |
@d kchar_given=char_given+1 {cjk character code defined by \.{\\kchardef}} |
| 270 |
@d math_given=kchar_given+1 {math code defined by \.{\\mathchardef}} |
| 271 |
@z |
| 272 |
|
| 273 |
@x |
| 274 |
@d partoken_name=set_auto_spacing+1 {set |par_token| name} |
| 275 |
@y |
| 276 |
@d set_enable_cjk_token=set_auto_spacing+1 {set cjk mode |
| 277 |
( \.{\\enablecjktoken}, \.{\\disablecjktoken}, \.{\\forcecjktoken} )} |
| 278 |
@d partoken_name=set_enable_cjk_token+1 {set |par_token| name} |
| 279 |
@z |
| 280 |
|
| 281 |
@x |
| 282 |
@d single_base=active_base+256 {equivalents of one-character control sequences} |
| 283 |
@d null_cs=single_base+256 {equivalent of \.{\\csname\\endcsname}} |
| 284 |
@y |
| 285 |
@d single_base=active_base+max_latin_val {equivalents of one-character control sequences} |
| 286 |
@d null_cs=single_base+max_latin_val {equivalent of \.{\\csname\\endcsname}} |
| 287 |
@z |
| 288 |
|
| 289 |
@x |
| 290 |
@d cat_code_base=auto_xspacing_code+1 |
| 291 |
{table of 256 command codes (the ``catcodes'')} |
| 292 |
@d kcat_code_base=cat_code_base+256 |
| 293 |
{table of 256 command codes for the wchar's catcodes } |
| 294 |
@d auto_xsp_code_base=kcat_code_base+256 {table of 256 auto spacer flag} |
| 295 |
@d inhibit_xsp_code_base=auto_xsp_code_base+256 |
| 296 |
@y |
| 297 |
@d enable_cjk_token_code=auto_xspacing_code+1 |
| 298 |
@d cat_code_base=enable_cjk_token_code+1 |
| 299 |
{table of |max_latin_val| command codes (the ``catcodes'')} |
| 300 |
@d kcat_code_base=cat_code_base+max_latin_val |
| 301 |
{table of 512 command codes for the wchar's catcodes } |
| 302 |
@d auto_xsp_code_base=kcat_code_base+512 |
| 303 |
{table of |max_latin_val| auto spacer flag} |
| 304 |
@d inhibit_xsp_code_base=auto_xsp_code_base+max_latin_val |
| 305 |
@z |
| 306 |
|
| 307 |
@x |
| 308 |
@d lc_code_base=kansuji_base+10 {table of 256 lowercase mappings} |
| 309 |
@d uc_code_base=lc_code_base+256 {table of 256 uppercase mappings} |
| 310 |
@d sf_code_base=uc_code_base+256 {table of 256 spacefactor mappings} |
| 311 |
@d math_code_base=sf_code_base+256 {table of 256 math mode mappings} |
| 312 |
@d char_sub_code_base=math_code_base+256 {table of character substitutions} |
| 313 |
@d int_base=char_sub_code_base+256 {beginning of region 5} |
| 314 |
@y |
| 315 |
@d lc_code_base=kansuji_base+10 {table of |max_latin_val| lowercase mappings} |
| 316 |
@d uc_code_base=lc_code_base+max_latin_val {table of |max_latin_val| uppercase mappings} |
| 317 |
@d sf_code_base=uc_code_base+max_latin_val {table of |max_latin_val| spacefactor mappings} |
| 318 |
@d math_code_base=sf_code_base+max_latin_val {table of 256 math mode mappings} |
| 319 |
@d char_sub_code_base=math_code_base+256 {table of character substitutions} |
| 320 |
@d int_base=char_sub_code_base+256 {beginning of region 5} |
| 321 |
@z |
| 322 |
|
| 323 |
@x |
| 324 |
@d auto_xspacing==equiv(auto_xspacing_code) |
| 325 |
@y |
| 326 |
@d auto_xspacing==equiv(auto_xspacing_code) |
| 327 |
@d enable_cjk_token==equiv(enable_cjk_token_code) |
| 328 |
@z |
| 329 |
|
| 330 |
@x |
| 331 |
eqtb[auto_xspacing_code]:=eqtb[cat_code_base]; |
| 332 |
for k:=0 to 255 do |
| 333 |
begin cat_code(k):=other_char; kcat_code(k):=other_kchar; |
| 334 |
math_code(k):=hi(k); sf_code(k):=1000; |
| 335 |
auto_xsp_code(k):=0; |
| 336 |
end; |
| 337 |
@y |
| 338 |
eqtb[auto_xspacing_code]:=eqtb[cat_code_base]; |
| 339 |
eqtb[enable_cjk_token_code]:=eqtb[cat_code_base]; |
| 340 |
for k:=0 to 255 do |
| 341 |
begin math_code(k):=hi(k); |
| 342 |
end; |
| 343 |
for k:=0 to max_latin_val-1 do |
| 344 |
begin cat_code(k):=other_char; sf_code(k):=1000; |
| 345 |
auto_xsp_code(k):=0; |
| 346 |
end; |
| 347 |
for k:=0 to 511 do |
| 348 |
begin kcat_code(k):=other_kchar; |
| 349 |
end; |
| 350 |
@z |
| 351 |
|
| 352 |
@x |
| 353 |
@t\hskip10pt@>kcat_code(@"20+1):=other_kchar; {1 ku} |
| 354 |
@t\hskip10pt@>kcat_code(@"20+2):=other_kchar; {2 ku} |
| 355 |
@+@t\1@>for k:=3 to 6 do kcat_code(@"20+k):=kana; {3 ku ... 6 ku} |
| 356 |
@+@t\1@>for k:=7 to 8 do kcat_code(@"20+k):=other_kchar; {7 ku ... 8 ku} |
| 357 |
@+@t\1@>for k:=16 to 84 do kcat_code(@"20+k):=kanji; {16 ku ... 84 ku} |
| 358 |
{ $\.{@@"20}+|k| = |kcatcodekey|(|fromKUTEN|(|HILO|(k,1))$ } |
| 359 |
@y |
| 360 |
if (isinternalUPTEX) then begin |
| 361 |
{ default: |other_kchar| } |
| 362 |
@t\hskip10pt@>kcat_code(@"0):=not_cjk; |
| 363 |
@+@t\1@>for k:=@"2 to @"3 do kcat_code(k):=not_cjk; { Latin Extended-A, Latin Extended-B } |
| 364 |
@t\hskip10pt@>kcat_code(@"25):=hangul; { Hangul Jamo } |
| 365 |
@t\hskip10pt@>kcat_code(@"46):=not_cjk; { Latin Extended Additional } |
| 366 |
@+@t\1@>for k:=@"68 to @"69 do kcat_code(k):=kanji; { CJK Radicals Supplement .. Kangxi Radicals } |
| 367 |
@+@t\1@>for k:=@"6C to @"6D do kcat_code(k):=kana; { Hiragana, Katakana } |
| 368 |
@t\hskip10pt@>kcat_code(@"6E):=kanji; { Bopomofo } |
| 369 |
@t\hskip10pt@>kcat_code(@"6F):=hangul; { Hangul Compatibility Jamo } |
| 370 |
@+@t\1@>for k:=@"70 to @"72 do kcat_code(k):=kanji; { Kanbun .. CJK Strokes } |
| 371 |
@t\hskip10pt@>kcat_code(@"73):=kana; { Katakana Phonetic Extensions } |
| 372 |
@t\hskip10pt@>kcat_code(@"76):=kanji; { CJK Unified Ideographs Extension A } |
| 373 |
@t\hskip10pt@>kcat_code(@"78):=kanji; { CJK Unified Ideographs } |
| 374 |
@t\hskip10pt@>kcat_code(@"88):=hangul; { Hangul Jamo Extended-A } |
| 375 |
@t\hskip10pt@>kcat_code(@"93):=hangul; { Hangul Syllables } |
| 376 |
@t\hskip10pt@>kcat_code(@"94):=hangul; { Hangul Jamo Extended-B } |
| 377 |
@t\hskip10pt@>kcat_code(@"99):=kanji; { CJK Compatibility Ideographs } |
| 378 |
@t\hskip10pt@>kcat_code(@"9C):=modifier; { Variation Selectors } |
| 379 |
{ \hskip10pt|kcat_code(@"A2):=other_kchar;| Halfwidth and Fullwidth Forms } |
| 380 |
@+@t\1@>for k:=@"11A to @"11D do kcat_code(k):=kana; { Kana Extended-B .. Small Kana Extension } |
| 381 |
@+@t\1@>for k:=@"14C to @"156 do kcat_code(k):=kanji; { CJK Unified Ideographs Extension B .. J } |
| 382 |
@t\hskip10pt@>kcat_code(@"162):=modifier; { Variation Selectors Supplement } |
| 383 |
@+@t\1@>for k:=@"1F9 to @"1FC do kcat_code(k):=modifier; |
| 384 |
{ Combining Katakana-Hiragana (Semi-)Voiced Sound Mark .. Emoji Modifier Fitzpatrick } |
| 385 |
@t\hskip10pt@>kcat_code(@"1FD):=not_cjk; { Latin-1 Letters } |
| 386 |
@t\hskip10pt@>kcat_code(@"1FE):=kana; { Fullwidth digit and latin alphabet } |
| 387 |
@t\hskip10pt@>kcat_code(@"1FF):=kana; { Halfwidth katakana } |
| 388 |
end else begin |
| 389 |
@t\hskip10pt@>kcat_code(@"20+1):=other_kchar; {1 ku} |
| 390 |
@t\hskip10pt@>kcat_code(@"20+2):=other_kchar; {2 ku} |
| 391 |
@+@t\1@>for k:=3 to 6 do kcat_code(@"20+k):=kana; {3 ku ... 6 ku} |
| 392 |
@+@t\1@>for k:=7 to 13 do kcat_code(@"20+k):=other_kchar; {7 ku ... 13 ku} |
| 393 |
@+@t\1@>for k:=14 to 120 do kcat_code(@"20+k):=kanji; {14 ku ... 120 ku} |
| 394 |
{ $\.{@@"20}+|k| = |kcatcodekey|(|fromKUTEN|(|HILO|(k,1))$ } |
| 395 |
@+@t\1@>for k:=16 to 94 do kcat_code(@"A0+k):=kanji; {2 men 16 ku ... 94 ku} |
| 396 |
end; |
| 397 |
@+@t\1@>for k:=@"166 to @"169 do kcat_code(k):=kanji; { for japanese-otf, japanese-otf-uptex } |
| 398 |
@+@t\1@>for k:=@"177 to @"178 do kcat_code(k):=kana; { Kana with (Semi-)Voiced Sound Mark } |
| 399 |
@t\hskip10pt@>kcat_code(@"17C):=kanji; { Standardized Variation Sequence } |
| 400 |
@+@t\1@>for k:=@"17E to @"17F do kcat_code(k):=kanji; { Ideographic Variation Sequence } |
| 401 |
@z |
| 402 |
|
| 403 |
@x |
| 404 |
@d enc_jis=1 |
| 405 |
@d enc_ucs=2 |
| 406 |
@y |
| 407 |
@d enc_jis=1 |
| 408 |
@d enc_ucs=2 |
| 409 |
@d enc_t1=@"80 |
| 410 |
@d enc_ts1=@"81 |
| 411 |
@d enc_ly1=@"82 |
| 412 |
@d enc_t5=@"83 |
| 413 |
@d enc_l7x=@"84 |
| 414 |
@d enc_t2a=@"90 |
| 415 |
@d enc_t2b=@"91 |
| 416 |
@d enc_t2c=@"92 |
| 417 |
@d enc_lgr=@"A0 |
| 418 |
@z |
| 419 |
|
| 420 |
@x |
| 421 |
begin if s<256 then cur_val:=s+single_base |
| 422 |
@y |
| 423 |
begin if s<256 then cur_val:=s+single_base |
| 424 |
@z |
| 425 |
|
| 426 |
@x l.5897 - upTeX |
| 427 |
primitive("char",char_num,0);@/ |
| 428 |
@!@:char_}{\.{\\char} primitive@> |
| 429 |
@y |
| 430 |
primitive("char",char_num,0);@/ |
| 431 |
@!@:char_}{\.{\\char} primitive@> |
| 432 |
primitive("kchar",kchar_num,0);@/ |
| 433 |
@!@:kchar_}{\.{\\kchar} primitive@> |
| 434 |
@z |
| 435 |
|
| 436 |
@x |
| 437 |
primitive("relax",relax,256); {cf.\ |scan_file_name|} |
| 438 |
@y |
| 439 |
primitive("relax",relax,max_cjk_val); {cf.\ |scan_file_name|} |
| 440 |
@z |
| 441 |
|
| 442 |
@x |
| 443 |
char_num: print_esc("char"); |
| 444 |
@y |
| 445 |
char_num: print_esc("char"); |
| 446 |
kchar_num: print_esc("kchar"); |
| 447 |
@z |
| 448 |
|
| 449 |
@x |
| 450 |
if font_enc[f]=enc_ucs then print("+Unicode") |
| 451 |
else if font_enc[f]=enc_jis then print("+JIS"); |
| 452 |
@y |
| 453 |
if font_enc[f]=enc_ucs then print("+Unicode") |
| 454 |
else if font_enc[f]=enc_jis then print("+JIS") |
| 455 |
else if font_enc[f]=enc_t1 then print("+T1") |
| 456 |
else if font_enc[f]=enc_ts1 then print("+TS1") |
| 457 |
else if font_enc[f]=enc_ly1 then print("+LY1") |
| 458 |
else if font_enc[f]=enc_t5 then print("+T5") |
| 459 |
else if font_enc[f]=enc_l7x then print("+L7x") |
| 460 |
else if font_enc[f]=enc_t2a then print("+T2A") |
| 461 |
else if font_enc[f]=enc_t2b then print("+T2B") |
| 462 |
else if font_enc[f]=enc_t2c then print("+T2C") |
| 463 |
else if font_enc[f]=enc_lgr then print("+LGR"); |
| 464 |
@z |
| 465 |
|
| 466 |
@x |
| 467 |
@d cs_token_flag==@"FFFF {amount added to the |eqtb| location in a |
| 468 |
token that stands for a control sequence; is a multiple of~256, less~1} |
| 469 |
@d left_brace_token=@'0400 {$2^8\cdot|left_brace|$} |
| 470 |
@d left_brace_limit=@'1000 {$2^8\cdot(|left_brace|+1)$} |
| 471 |
@d right_brace_token=@'1000 {$2^8\cdot|right_brace|$} |
| 472 |
@d right_brace_limit=@'1400 {$2^8\cdot(|right_brace|+1)$} |
| 473 |
@d math_shift_token=@'1400 {$2^8\cdot|math_shift|$} |
| 474 |
@d tab_token=@'2000 {$2^8\cdot|tab_mark|$} |
| 475 |
@d out_param_token=@'2400 {$2^8\cdot|out_param|$} |
| 476 |
@d space_token=@'5040 {$2^8\cdot|spacer|+|" "|$} |
| 477 |
@d letter_token=@'5400 {$2^8\cdot|letter|$} |
| 478 |
@d other_token=@'6000 {$2^8\cdot|other_char|$} |
| 479 |
@d match_token=@'6400 {$2^8\cdot|match|$} |
| 480 |
@d end_match_token=@'7000 {$2^8\cdot|end_match|$} |
| 481 |
@y |
| 482 |
@d cs_token_flag=@"1FFFFFFF {amount added to the |eqtb| location in a |
| 483 |
token that stands for a control sequence; is a multiple of~@@"1000000, less~1} |
| 484 |
@d max_char_val=@"10000 {to separate char and command code} |
| 485 |
@d left_brace_token=@"10000 {$2^16\cdot|left_brace|$} |
| 486 |
@d left_brace_limit=@"20000 {$2^16\cdot(|left_brace|+1)$} |
| 487 |
@d right_brace_token=@"20000 {$2^16\cdot|right_brace|$} |
| 488 |
@d right_brace_limit=@"30000 {$2^16\cdot(|right_brace|+1)$} |
| 489 |
@d math_shift_token=@"30000 {$2^16\cdot|math_shift|$} |
| 490 |
@d tab_token=@"40000 {$2^16\cdot|tab_mark|$} |
| 491 |
@d out_param_token=@"50000 {$2^16\cdot|out_param|$} |
| 492 |
@d space_token=@"A0020 {$2^16\cdot|spacer|+|" "|$} |
| 493 |
@d letter_token=@"B0000 {$2^16\cdot|letter|$} |
| 494 |
@d other_token=@"C0000 {$2^16\cdot|other_char|$} |
| 495 |
@d match_token=@"D0000 {$2^16\cdot|match|$} |
| 496 |
@d end_match_token=@"E0000 {$2^16\cdot|end_match|$} |
| 497 |
@z |
| 498 |
|
| 499 |
@x |
| 500 |
procedure show_token_list(@!p,@!q:integer;@!l:integer); |
| 501 |
label exit; |
| 502 |
var m,@!c:integer; {pieces of a token} |
| 503 |
@!match_chr:ASCII_code; {character used in a `|match|'} |
| 504 |
@y |
| 505 |
procedure show_token_list(@!p,@!q:integer;@!l:integer); |
| 506 |
label exit; |
| 507 |
var m,@!c:integer; {pieces of a token} |
| 508 |
@!match_chr:0..max_latin_val; {character used in a `|match|'} |
| 509 |
@z |
| 510 |
|
| 511 |
@x |
| 512 |
if check_kanji(info(p)) then {|wchar_token|} |
| 513 |
begin m:=kcat_code(kcatcodekey(info(p))); c:=info(p); |
| 514 |
end |
| 515 |
else begin m:=Hi(info(p)); c:=Lo(info(p)); |
| 516 |
end; |
| 517 |
if (m<kanji)and(c>256) then print_esc("BAD.") |
| 518 |
@.BAD@> |
| 519 |
@y |
| 520 |
if check_kanji(info(p)) then {|wchar_token|} |
| 521 |
begin |
| 522 |
m:=ktokentocmd(info(p)); |
| 523 |
c:=ktokentochr(info(p)); |
| 524 |
end |
| 525 |
else begin m:=info(p) div max_char_val; c:=info(p) mod max_char_val; |
| 526 |
end; |
| 527 |
if (m<kanji)and(c>=max_latin_val) then print_esc("BAD.") |
| 528 |
@.BAD@> |
| 529 |
@z |
| 530 |
|
| 531 |
@x |
| 532 |
@<Display the token ...@>= |
| 533 |
case m of |
| 534 |
kanji,kana,other_kchar: print_kanji(KANJI(c)); |
| 535 |
left_brace,right_brace,math_shift,tab_mark,sup_mark,sub_mark,spacer, |
| 536 |
letter,other_char: print(c); |
| 537 |
mac_param: begin print(c); print(c); |
| 538 |
end; |
| 539 |
out_param: begin print(match_chr); |
| 540 |
if c<=9 then print_char(c+"0") |
| 541 |
else begin print_char("!"); return; |
| 542 |
end; |
| 543 |
end; |
| 544 |
match: begin match_chr:=c; print(c); incr(n); print_char(n); |
| 545 |
if n>"9" then return; |
| 546 |
end; |
| 547 |
@y |
| 548 |
@<Display the token ...@>= |
| 549 |
case m of |
| 550 |
kanji,kana,other_kchar,hangul,modifier: print_kanji(KANJI(c)); |
| 551 |
left_brace,right_brace,math_shift,tab_mark,sup_mark,sub_mark,spacer, |
| 552 |
letter,other_char: if (check_echar_range(c)=1)or(check_mchar_range(c)) |
| 553 |
then print_kanji(KANJI(c)) else print(c); |
| 554 |
mac_param: begin if (check_echar_range(c)=1)or(check_mchar_range(c)) |
| 555 |
then begin print_kanji(KANJI(c)); print_kanji(KANJI(c)); end |
| 556 |
else begin print(c); print(c); end |
| 557 |
end; |
| 558 |
out_param: begin |
| 559 |
if (check_echar_range(match_chr)=1)or(check_mchar_range(match_chr)) |
| 560 |
then print_kanji(KANJI(match_chr)) else print(match_chr); |
| 561 |
if c<=9 then print_char(c+"0") |
| 562 |
else begin print_char("!"); return; |
| 563 |
end; |
| 564 |
end; |
| 565 |
match: begin match_chr:=c; |
| 566 |
if (check_echar_range(c)=1)or(check_mchar_range(c)) |
| 567 |
then print_kanji(KANJI(c)) else print(c); |
| 568 |
incr(n); print_char(n); |
| 569 |
if n>"9" then return; |
| 570 |
end; |
| 571 |
@z |
| 572 |
|
| 573 |
@x |
| 574 |
@d chr_cmd(#)==begin print(#); print_ASCII(chr_code); |
| 575 |
end |
| 576 |
@y |
| 577 |
@d chr_cmd(#)==begin print(#); |
| 578 |
if chr_code < @"100 then print_ASCII(chr_code) |
| 579 |
else print_kanji(chr_code); |
| 580 |
end |
| 581 |
@z |
| 582 |
|
| 583 |
@x |
| 584 |
kanji,kana,other_kchar: begin print("kanji character "); |
| 585 |
@y |
| 586 |
kanji,kana,other_kchar,hangul,modifier: begin print("kanji character "); |
| 587 |
@z |
| 588 |
|
| 589 |
@x |
| 590 |
if (first_count>0)and(trick_buf2[(first_count-1)mod error_line]=1) then |
| 591 |
incr(first_count); |
| 592 |
@y |
| 593 |
kcp:=trick_buf2[(first_count-1)mod error_line]; |
| 594 |
if (first_count>0)and(kcp>0) then |
| 595 |
first_count:=first_count+nrestmultichr(kcp); |
| 596 |
@z |
| 597 |
|
| 598 |
@x |
| 599 |
if trick_buf2[p mod error_line]=2 then |
| 600 |
begin p:=p+1; n:=n-1; |
| 601 |
end; |
| 602 |
@y |
| 603 |
kcp:=trick_buf2[p mod error_line]; |
| 604 |
if (kcp mod @'10)>1 then begin |
| 605 |
p:=p+nrestmultichr(kcp)+1; n:=n-nrestmultichr(kcp)-1; end; |
| 606 |
@z |
| 607 |
|
| 608 |
@x |
| 609 |
if trick_buf2[(p-1) mod error_line]=1 then p:=p-1; |
| 610 |
@y |
| 611 |
kcp:=trick_buf2[(p-1) mod error_line]; |
| 612 |
if ((kcp mod @'10)>0)and(nrestmultichr(kcp)>0) then p:=p-(kcp mod @'10); |
| 613 |
@z |
| 614 |
|
| 615 |
@x |
| 616 |
s:=get_avail; info(s):=Lo(info(loc)); |
| 617 |
@y |
| 618 |
s:=get_avail; info(s):=ktokentochr(info(loc)); |
| 619 |
@z |
| 620 |
|
| 621 |
@x |
| 622 |
primitive("par",par_end,256); {cf.\ |scan_file_name|} |
| 623 |
@y |
| 624 |
primitive("par",par_end,max_cjk_val); {cf.\ |scan_file_name|} |
| 625 |
@z |
| 626 |
|
| 627 |
@x |
| 628 |
@!c,@!cc:ASCII_code; {constituents of a possible expanded code} |
| 629 |
@!d:2..3; {number of excess characters in an expanded code} |
| 630 |
@y |
| 631 |
@!c,@!cc,@!cd,@!ce:ASCII_code; {constituents of a possible expanded code} |
| 632 |
@!d:2..7; {number of excess characters in an expanded code} |
| 633 |
@z |
| 634 |
|
| 635 |
@x |
| 636 |
begin cur_chr:=buffer[loc]; incr(loc); |
| 637 |
if multistrlen(ustringcast(buffer), limit+1, loc-1)=2 then |
| 638 |
begin cur_chr:=fromBUFF(ustringcast(buffer), limit+1, loc-1); |
| 639 |
cur_cmd:=kcat_code(kcatcodekey(cur_chr)); |
| 640 |
for l:=loc-1 to loc-2+multistrlen(ustringcast(buffer), limit+1, loc-1) do |
| 641 |
buffer2[l]:=1; |
| 642 |
incr(loc); |
| 643 |
end |
| 644 |
else reswitch: cur_cmd:=cat_code(cur_chr); |
| 645 |
@y |
| 646 |
begin |
| 647 |
cur_chr:=fromBUFF(ustringcast(buffer), limit+1, loc); |
| 648 |
cur_cmd:=kcat_code(kcatcodekey(cur_chr)); |
| 649 |
if (multistrlen(ustringcast(buffer), limit+1, loc)>1) and check_kcat_code(cur_cmd,cur_chr) then begin |
| 650 |
if (cur_cmd=latin_ucs) then cur_cmd:=cat_code(cur_chr); |
| 651 |
if (cur_cmd=not_cjk) then cur_cmd:=other_kchar; |
| 652 |
for l:=loc to loc-1+multistrlen(ustringcast(buffer), limit+1, loc) do |
| 653 |
buffer2[l]:=1; |
| 654 |
loc:=loc+multistrlen(ustringcast(buffer), limit+1, loc) end |
| 655 |
else begin |
| 656 |
cur_chr:=buffer[loc]; incr(loc); |
| 657 |
reswitch: cur_cmd:=cat_code(cur_chr); |
| 658 |
end; |
| 659 |
@z |
| 660 |
|
| 661 |
@x |
| 662 |
@ @d add_delims_to(#)==#+math_shift,#+tab_mark,#+mac_param, |
| 663 |
#+sub_mark,#+letter,#+other_char |
| 664 |
@d all_jcode(#)==#+kanji,#+kana,#+other_kchar |
| 665 |
@y |
| 666 |
@ @d add_delims_to(#)==#+math_shift,#+tab_mark,#+mac_param, |
| 667 |
#+sub_mark,#+letter,#+other_char |
| 668 |
@d all_jcode(#)==#+kanji,#+kana,#+other_kchar,#+modifier |
| 669 |
@d hangul_code(#)==#+hangul |
| 670 |
@z |
| 671 |
|
| 672 |
@x |
| 673 |
all_jcode(skip_blanks),all_jcode(skip_blanks_kanji),all_jcode(new_line), |
| 674 |
all_jcode(mid_line): |
| 675 |
state:=mid_kanji; |
| 676 |
@y |
| 677 |
all_jcode(skip_blanks),all_jcode(skip_blanks_kanji),all_jcode(new_line), |
| 678 |
all_jcode(mid_line): |
| 679 |
state:=mid_kanji; |
| 680 |
hangul_code(skip_blanks),hangul_code(skip_blanks_kanji),hangul_code(new_line), |
| 681 |
hangul_code(mid_kanji): |
| 682 |
state:=mid_line; |
| 683 |
@z |
| 684 |
|
| 685 |
@x |
| 686 |
@d hex_to_cur_chr== |
| 687 |
if c<="9" then cur_chr:=c-"0" @+else cur_chr:=c-"a"+10; |
| 688 |
if cc<="9" then cur_chr:=16*cur_chr+cc-"0" |
| 689 |
else cur_chr:=16*cur_chr+cc-"a"+10 |
| 690 |
@y |
| 691 |
@d hex_to_cur_chr== |
| 692 |
if c<="9" then cur_chr:=c-"0" @+else cur_chr:=c-"a"+10; |
| 693 |
if cc<="9" then cur_chr:=16*cur_chr+cc-"0" |
| 694 |
else cur_chr:=16*cur_chr+cc-"a"+10 |
| 695 |
@d long_hex_to_cur_chr== |
| 696 |
if c<="9" then cur_chr:=c-"0" @+else cur_chr:=c-"a"+10; |
| 697 |
if cc<="9" then cur_chr:=16*cur_chr+cc-"0" |
| 698 |
else cur_chr:=16*cur_chr+cc-"a"+10; |
| 699 |
if cd<="9" then cur_chr:=16*cur_chr+cd-"0" |
| 700 |
else cur_chr:=16*cur_chr+cd-"a"+10; |
| 701 |
if ce<="9" then cur_chr:=16*cur_chr+ce-"0" |
| 702 |
else cur_chr:=16*cur_chr+ce-"a"+10 |
| 703 |
@z |
| 704 |
|
| 705 |
@x |
| 706 |
begin c:=buffer[loc+1]; @+if c<@'200 then {yes we have an expanded char} |
| 707 |
@y |
| 708 |
begin if (isinternalUPTEX) and ((loc+6)<=limit) and |
| 709 |
(cur_chr=buffer[loc+1]) and (cur_chr=buffer[loc+2]) then |
| 710 |
begin c:=buffer[loc+3]; cc:=buffer[loc+4]; |
| 711 |
cd:=buffer[loc+5]; ce:=buffer[loc+6]; |
| 712 |
if is_hex(c) and is_hex(cc) and is_hex(cd) and is_hex(ce) then |
| 713 |
begin long_hex_to_cur_chr; |
| 714 |
if (cur_chr<max_latin_val) then begin |
| 715 |
loc:=loc+7; |
| 716 |
goto reswitch; |
| 717 |
end; |
| 718 |
end; |
| 719 |
end; |
| 720 |
c:=buffer[loc+1]; @+if c<@'200 then {yes we have an expanded char} |
| 721 |
@z |
| 722 |
|
| 723 |
@x |
| 724 |
else begin k:=loc; cur_chr:=buffer[k]; incr(k); |
| 725 |
if multistrlen(ustringcast(buffer), limit+1, k-1)=2 then |
| 726 |
begin cat:=kcat_code(kcatcodekey(fromBUFF(ustringcast(buffer), limit+1, k-1))); |
| 727 |
for l:=k-1 to k-2+multistrlen(ustringcast(buffer), limit+1, k-1) do |
| 728 |
buffer2[l]:=1; |
| 729 |
incr(k); |
| 730 |
end |
| 731 |
else cat:=cat_code(cur_chr); |
| 732 |
start_cs: |
| 733 |
if cat=letter then state:=skip_blanks |
| 734 |
@y |
| 735 |
else begin k:=loc; |
| 736 |
cur_chr:=fromBUFF(ustringcast(buffer), limit+1, k); |
| 737 |
cat:=kcat_code(kcatcodekey(cur_chr)); |
| 738 |
if (multistrlen(ustringcast(buffer), limit+1, k)>1) and check_kcat_code(cat,cur_chr) then begin |
| 739 |
if (cat=latin_ucs)or(cat=not_cjk) then cat:=other_kchar; |
| 740 |
for l:=k to k-1+multistrlen(ustringcast(buffer), limit+1, k) do |
| 741 |
buffer2[l]:=1; |
| 742 |
k:=k+multistrlen(ustringcast(buffer), limit+1, k) end |
| 743 |
else begin {not multi-byte char} |
| 744 |
cur_chr:=buffer[k]; |
| 745 |
cat:=cat_code(cur_chr); |
| 746 |
incr(k); |
| 747 |
end; |
| 748 |
start_cs: |
| 749 |
if (cat=letter)or(cat=hangul) then state:=skip_blanks |
| 750 |
@z |
| 751 |
|
| 752 |
@x |
| 753 |
else if ((cat=letter)or(cat=kanji)or(cat=kana))and(k<=limit) then |
| 754 |
@y |
| 755 |
else if ((cat=letter)or(cat=kanji)or(cat=kana)or(cat=hangul)or(cat=modifier))and(k<=limit) then |
| 756 |
@z |
| 757 |
|
| 758 |
@x |
| 759 |
if (cat=kanji)or(cat=kana) then |
| 760 |
@y |
| 761 |
if (cat=kanji)or(cat=kana)or(cat=hangul)or(cat=modifier) then |
| 762 |
@z |
| 763 |
|
| 764 |
@x |
| 765 |
begin repeat cur_chr:=buffer[k]; incr(k); |
| 766 |
if multistrlen(ustringcast(buffer), limit+1, k-1)=2 then |
| 767 |
begin cat:=kcat_code(kcatcodekey(fromBUFF(ustringcast(buffer), limit+1, k-1))); |
| 768 |
for l:=k-1 to k-2+multistrlen(ustringcast(buffer), limit+1, k-1) do |
| 769 |
buffer2[l]:=1; |
| 770 |
incr(k); |
| 771 |
if (cat=kanji)or(cat=kana) then |
| 772 |
begin if (ptex_lineend mod 2)=0 then state:=skip_blanks_kanji |
| 773 |
else state:=skip_blanks end; |
| 774 |
end |
| 775 |
else cat:=cat_code(cur_chr); |
| 776 |
@y |
| 777 |
begin repeat |
| 778 |
cur_chr:=fromBUFF(ustringcast(buffer), limit+1, k); |
| 779 |
cat:=kcat_code(kcatcodekey(cur_chr)); |
| 780 |
if (multistrlen(ustringcast(buffer), limit+1, k)>1) and check_kcat_code(cat,cur_chr) then begin |
| 781 |
if (cat=latin_ucs) then cat:=cat_code(cur_chr); |
| 782 |
if (cat=not_cjk) then cat:=other_kchar; |
| 783 |
for l:=k to k-1+multistrlen(ustringcast(buffer), limit+1, k) do |
| 784 |
buffer2[l]:=1; |
| 785 |
k:=k+multistrlen(ustringcast(buffer), limit+1, k); |
| 786 |
if (cat=kanji)or(cat=kana) then |
| 787 |
begin if (ptex_lineend mod 2)=0 then state:=skip_blanks_kanji |
| 788 |
else state:=skip_blanks end |
| 789 |
else if cat=hangul then state:=skip_blanks; |
| 790 |
end |
| 791 |
else begin {not multi-byte char} |
| 792 |
cur_chr:=buffer[k]; |
| 793 |
cat:=cat_code(cur_chr); |
| 794 |
incr(k); |
| 795 |
end; |
| 796 |
@z |
| 797 |
|
| 798 |
@x |
| 799 |
until not((cat=letter)or(cat=kanji)or(cat=kana))or(k>limit); |
| 800 |
{@@<If an expanded...@@>;} |
| 801 |
if not((cat=letter)or(cat=kanji)or(cat=kana)) then decr(k); |
| 802 |
if cat=other_kchar then decr(k); {now |k| points to first nonletter} |
| 803 |
@y |
| 804 |
until not((cat=letter)or(cat=kanji)or(cat=kana)or(cat=hangul)or(cat=modifier))or(k>limit); |
| 805 |
{@@<If an expanded...@@>;} |
| 806 |
if not((cat=letter)or(cat=kanji)or(cat=kana)or(cat=hangul)or(cat=modifier)) then begin |
| 807 |
if (buffer2[k-1]) then k:=k-multilenbuffchar(cur_chr) |
| 808 |
else decr(k); |
| 809 |
end; {now |k| points to first nonletter} |
| 810 |
@z |
| 811 |
|
| 812 |
@x |
| 813 |
else if check_kanji(t) then {|wchar_token|} |
| 814 |
begin cur_chr:=t; cur_cmd:=kcat_code(kcatcodekey(t)); |
| 815 |
end |
| 816 |
else |
| 817 |
begin cur_cmd:=Hi(t); cur_chr:=Lo(t); |
| 818 |
@y |
| 819 |
else if check_kanji(t) then {|wchar_token|} |
| 820 |
begin |
| 821 |
cur_cmd:=ktokentocmd(t); |
| 822 |
cur_chr:=ktokentochr(t); |
| 823 |
end |
| 824 |
else |
| 825 |
begin cur_cmd:=t div max_char_val; cur_chr:=t mod max_char_val; |
| 826 |
@z |
| 827 |
|
| 828 |
@x |
| 829 |
@d no_expand_flag=257 {this characterizes a special variant of |relax|} |
| 830 |
@y |
| 831 |
@d no_expand_flag=max_cjk_val+1 {this characterizes a special variant of |relax|} |
| 832 |
@z |
| 833 |
|
| 834 |
@x get_token |
| 835 |
if (cur_cmd=kanji)or(cur_cmd=kana)or(cur_cmd=other_kchar) then {|wchar_token|} |
| 836 |
cur_tok:=cur_chr |
| 837 |
else cur_tok:=(cur_cmd*@'400)+cur_chr |
| 838 |
@y |
| 839 |
if (cur_cmd>=kanji)and(cur_cmd<=modifier) then {|wchar_token|} |
| 840 |
if (cur_cmd=kanji)and(cur_chr>=max_cjk_val) then |
| 841 |
cur_tok:=(kanji_ivs*max_cjk_val)+cur_chr |
| 842 |
else |
| 843 |
cur_tok:=(cur_cmd*max_cjk_val)+cur_chr |
| 844 |
else if (cur_cmd=latin_ucs) then |
| 845 |
cur_tok:=(cat_code(cur_chr)*max_cjk_val)+cur_chr |
| 846 |
else if (check_echar_range(cur_chr)=1) then |
| 847 |
cur_tok:=(cur_cmd*max_cjk_val)+cur_chr |
| 848 |
else cur_tok:=(cur_cmd*max_char_val)+cur_chr |
| 849 |
@z |
| 850 |
|
| 851 |
@x |
| 852 |
begin eq_define(cur_cs,relax,256); {N.B.: The |save_stack| might change} |
| 853 |
@y |
| 854 |
begin eq_define(cur_cs,relax,max_cjk_val); {N.B.: The |save_stack| might change} |
| 855 |
@z |
| 856 |
|
| 857 |
@x |
| 858 |
if check_kanji(info(p)) then {|wchar_token|} |
| 859 |
begin buffer[j]:=Hi(info(p)); buffer2[j]:=1; incr(j); buffer2[j]:=1; |
| 860 |
end |
| 861 |
else buffer2[j]:=0; |
| 862 |
buffer[j]:=Lo(info(p)); incr(j); p:=link(p); |
| 863 |
@y |
| 864 |
if check_kanji(info(p)) then {|wchar_token|} |
| 865 |
begin t:=toBUFF(info(p) mod max_cjk_val); |
| 866 |
if BYTE1(t)<>0 then begin buffer[j]:=BYTE1(t); buffer2[j]:=1; incr(j); end; |
| 867 |
if BYTE2(t)<>0 then begin buffer[j]:=BYTE2(t); buffer2[j]:=1; incr(j); end; |
| 868 |
if BYTE3(t)<>0 then begin buffer[j]:=BYTE3(t); buffer2[j]:=1; incr(j); end; |
| 869 |
buffer[j]:=BYTE4(t); buffer2[j]:=1; incr(j); |
| 870 |
p:=link(p); |
| 871 |
end |
| 872 |
else |
| 873 |
begin buffer[j]:=info(p) mod max_char_val; buffer2[j]:=0; incr(j); p:=link(p); |
| 874 |
end; |
| 875 |
@z |
| 876 |
|
| 877 |
@x get_x_token |
| 878 |
if (cur_cmd=kanji)or(cur_cmd=kana)or(cur_cmd=other_kchar) then |
| 879 |
cur_tok:=cur_chr |
| 880 |
else cur_tok:=(cur_cmd*@'400)+cur_chr |
| 881 |
@y |
| 882 |
if (cur_cmd>=kanji)and(cur_cmd<=modifier) then |
| 883 |
if (cur_cmd=kanji)and(cur_chr>=max_cjk_val) then |
| 884 |
cur_tok:=(kanji_ivs*max_cjk_val)+cur_chr |
| 885 |
else |
| 886 |
cur_tok:=(cur_cmd*max_cjk_val)+cur_chr |
| 887 |
else if (cur_cmd=latin_ucs) then |
| 888 |
cur_tok:=(cat_code(cur_chr)*max_cjk_val)+cur_chr |
| 889 |
else if (check_echar_range(cur_chr)=1) then |
| 890 |
cur_tok:=(cur_cmd*max_cjk_val)+cur_chr |
| 891 |
else cur_tok:=(cur_cmd*max_char_val)+cur_chr |
| 892 |
@z |
| 893 |
|
| 894 |
@x x_token |
| 895 |
if (cur_cmd=kanji)or(cur_cmd=kana)or(cur_cmd=other_kchar) then |
| 896 |
cur_tok:=cur_chr |
| 897 |
else cur_tok:=(cur_cmd*@'400)+cur_chr |
| 898 |
@y |
| 899 |
if (cur_cmd>=kanji)and(cur_cmd<=modifier) then |
| 900 |
if (cur_cmd=kanji)and(cur_chr>=max_cjk_val) then |
| 901 |
cur_tok:=(kanji_ivs*max_cjk_val)+cur_chr |
| 902 |
else |
| 903 |
cur_tok:=(cur_cmd*max_cjk_val)+cur_chr |
| 904 |
else if (cur_cmd=latin_ucs) then |
| 905 |
cur_tok:=(cat_code(cur_chr)*max_cjk_val)+cur_chr |
| 906 |
else if (check_echar_range(cur_chr)=1) then |
| 907 |
cur_tok:=(cur_cmd*max_cjk_val)+cur_chr |
| 908 |
else cur_tok:=(cur_cmd*max_char_val)+cur_chr |
| 909 |
@z |
| 910 |
|
| 911 |
@x |
| 912 |
if (info(r)>match_token+255)or(info(r)<match_token) then s:=null |
| 913 |
@y |
| 914 |
if (info(r)>=match_token+max_latin_val)or(info(r)<match_token) then s:=null |
| 915 |
@z |
| 916 |
|
| 917 |
@x |
| 918 |
char_given,math_given: scanned_result(cur_chr)(int_val); |
| 919 |
@y |
| 920 |
kchar_given, |
| 921 |
char_given,math_given: scanned_result(cur_chr)(int_val); |
| 922 |
@z |
| 923 |
|
| 924 |
@x |
| 925 |
else if m<math_code_base then { \.{\\lccode}, \.{\\uccode}, \.{\\sfcode}, \.{\\catcode} } |
| 926 |
begin scan_ascii_num; |
| 927 |
scanned_result(equiv(m+cur_val))(int_val) end |
| 928 |
@y |
| 929 |
else if m<math_code_base then { \.{\\lccode}, \.{\\uccode}, \.{\\sfcode}, \.{\\catcode} } |
| 930 |
begin scan_latin_num; |
| 931 |
scanned_result(equiv(m+cur_val))(int_val) end |
| 932 |
@z |
| 933 |
|
| 934 |
@x |
| 935 |
@d ptex_minor_version_code=ptex_version_code+1 {code for \.{\\ptexminorversion}} |
| 936 |
@y |
| 937 |
@d uptex_version_code=ptex_version_code+1 {code for \.{\\uptexversion}} |
| 938 |
@d ptex_minor_version_code=uptex_version_code+1 {code for \.{\\ptexminorversion}} |
| 939 |
@z |
| 940 |
|
| 941 |
@x |
| 942 |
primitive("ptexversion",last_item,ptex_version_code); |
| 943 |
@!@:ptexversion_}{\.{\\ptexversion} primitive@> |
| 944 |
@y |
| 945 |
primitive("ptexversion",last_item,ptex_version_code); |
| 946 |
@!@:ptexversion_}{\.{\\ptexversion} primitive@> |
| 947 |
primitive("uptexversion",last_item,uptex_version_code); |
| 948 |
@!@:uptexversion_}{\.{\\uptexversion} primitive@> |
| 949 |
@z |
| 950 |
|
| 951 |
@x |
| 952 |
ptex_version_code: print_esc("ptexversion"); |
| 953 |
@y |
| 954 |
ptex_version_code: print_esc("ptexversion"); |
| 955 |
uptex_version_code: print_esc("uptexversion"); |
| 956 |
@z |
| 957 |
|
| 958 |
@x |
| 959 |
ptex_version_code: cur_val:=pTeX_version; |
| 960 |
@y |
| 961 |
ptex_version_code: cur_val:=pTeX_version; |
| 962 |
uptex_version_code: cur_val:=upTeX_version; |
| 963 |
@z |
| 964 |
|
| 965 |
@x |
| 966 |
procedure scan_ascii_num; |
| 967 |
begin scan_int; |
| 968 |
if (cur_val<0)or(cur_val>255) then |
| 969 |
begin print_err("Bad character code"); |
| 970 |
@.Bad character code@> |
| 971 |
help2("A character number must be between 0 and 255.")@/ |
| 972 |
("I changed this one to zero."); int_error(cur_val); cur_val:=0; |
| 973 |
end; |
| 974 |
end; |
| 975 |
@y |
| 976 |
procedure scan_ascii_num; |
| 977 |
begin scan_int; |
| 978 |
if (cur_val<0)or(cur_val>255) then |
| 979 |
begin print_err("Bad character code"); |
| 980 |
@.Bad character code@> |
| 981 |
help2("A character number must be between 0 and 255.")@/ |
| 982 |
("I changed this one to zero."); int_error(cur_val); cur_val:=0; |
| 983 |
end; |
| 984 |
end; |
| 985 |
procedure scan_latin_num; |
| 986 |
begin scan_int; |
| 987 |
if not is_char_ascii(cur_val) then |
| 988 |
begin print_err("Bad character code"); |
| 989 |
@.Bad character code@> |
| 990 |
help2("A character number must be between 0 and ""2E7F.")@/ |
| 991 |
("I changed this one to zero."); int_error(cur_val); cur_val:=0; |
| 992 |
end; |
| 993 |
end; |
| 994 |
@z |
| 995 |
|
| 996 |
@x |
| 997 |
if (cur_cmd=kanji)or(cur_cmd=kana)or(cur_cmd=other_kchar) then {|wchar_token|} |
| 998 |
@y |
| 999 |
if (cur_cmd>=kanji)and(cur_cmd<=modifier) then {|wchar_token|} |
| 1000 |
@z |
| 1001 |
|
| 1002 |
@x |
| 1003 |
if str_start[m+1]-str_start[m] |
| 1004 |
= multistrlenshort(str_pool, str_start[m+1], str_start[m]) |
| 1005 |
then |
| 1006 |
cur_val:=fromBUFFshort(str_pool, str_start[m+1], str_start[m]) |
| 1007 |
else begin cur_cmd:=invalid_char; cur_val:=256; end; |
| 1008 |
end; |
| 1009 |
if (cur_val>255)and(cur_cmd<kanji) then |
| 1010 |
begin print_err("Improper alphabetic or KANJI constant"); |
| 1011 |
@y |
| 1012 |
if str_start[m+1]-str_start[m] |
| 1013 |
= multistrlenshort(str_pool, str_start[m+1], str_start[m]) |
| 1014 |
then |
| 1015 |
cur_val:=fromBUFFshort(str_pool, str_start[m+1], str_start[m]) |
| 1016 |
else begin cur_cmd:=invalid_char; cur_val:=max_cjk_val; end; |
| 1017 |
end; |
| 1018 |
if (cur_val>=max_latin_val)and(cur_cmd<kanji) then |
| 1019 |
begin print_err("Improper alphabetic or KANJI constant"); |
| 1020 |
@z |
| 1021 |
|
| 1022 |
@x |
| 1023 |
@!t:halfword; {token being appended} |
| 1024 |
@!k:pool_pointer; {index into |str_pool|} |
| 1025 |
begin str_room(1); |
| 1026 |
p:=temp_head; link(p):=null; k:=b; |
| 1027 |
while k<pool_ptr do |
| 1028 |
begin t:=so(str_pool[k]); |
| 1029 |
if t>=@"100 then |
| 1030 |
begin t:=fromBUFFshort(str_pool, pool_ptr, k); incr(k); |
| 1031 |
end |
| 1032 |
else if t=" " then t:=space_token |
| 1033 |
else t:=other_token+t; |
| 1034 |
@y |
| 1035 |
@!t:halfword; {token being appended} |
| 1036 |
@!k:pool_pointer; {index into |str_pool|} |
| 1037 |
@!cc:escape..max_char_code; |
| 1038 |
begin str_room(1); |
| 1039 |
p:=temp_head; link(p):=null; k:=b; |
| 1040 |
while k<pool_ptr do |
| 1041 |
begin t:=so(str_pool[k]); |
| 1042 |
if t>=@"180 then { there is no |wchar_token| whose code is 0--127. } |
| 1043 |
begin t:=fromBUFFshort(str_pool, pool_ptr, k); cc:=kcat_code(kcatcodekey(t)); |
| 1044 |
if (cc=latin_ucs) then cc:=other_char; |
| 1045 |
if (cc=not_cjk) then cc:=other_kchar; |
| 1046 |
if (cc=kanji)and(t>=max_cjk_val) then cc:=kanji_ivs; |
| 1047 |
t:=t+cc*max_cjk_val; |
| 1048 |
k:=k+multistrlenshort(str_pool, pool_ptr, k)-1; |
| 1049 |
end |
| 1050 |
else begin t:=so(str_pool[k]); |
| 1051 |
if t>=@"100 then t:=t-@"100; |
| 1052 |
if t=" " then t:=space_token |
| 1053 |
else t:=other_token+t; |
| 1054 |
end; |
| 1055 |
@z |
| 1056 |
|
| 1057 |
@x |
| 1058 |
@d ptex_revision_code=14 {command code for \.{\\ptexrevision}} |
| 1059 |
@d ptex_convert_codes=15 {end of \pTeX's command codes} |
| 1060 |
@y |
| 1061 |
@d ptex_revision_code=14 {command code for \.{\\ptexrevision}} |
| 1062 |
@d uptex_revision_code=15 {command code for \.{\\uptexrevision}} |
| 1063 |
@d ptex_convert_codes=16 {end of \pTeX's command codes} |
| 1064 |
@z |
| 1065 |
|
| 1066 |
@x |
| 1067 |
primitive("ptexrevision",convert,ptex_revision_code); |
| 1068 |
@!@:ptexrevision_}{\.{\\ptexrevision} primitive@> |
| 1069 |
@y |
| 1070 |
primitive("ptexrevision",convert,ptex_revision_code); |
| 1071 |
@!@:ptexrevision_}{\.{\\ptexrevision} primitive@> |
| 1072 |
primitive("uptexrevision",convert,uptex_revision_code); |
| 1073 |
@!@:uptexrevision_}{\.{\\uptexrevision} primitive@> |
| 1074 |
@z |
| 1075 |
|
| 1076 |
@x |
| 1077 |
ptex_revision_code:print_esc("ptexrevision"); |
| 1078 |
@y |
| 1079 |
ptex_revision_code:print_esc("ptexrevision"); |
| 1080 |
uptex_revision_code:print_esc("uptexrevision"); |
| 1081 |
@z |
| 1082 |
|
| 1083 |
@x |
| 1084 |
ptex_revision_code: do_nothing; |
| 1085 |
string_code, meaning_code: begin save_scanner_status:=scanner_status; |
| 1086 |
scanner_status:=normal; get_token; |
| 1087 |
if (cur_cmd=kanji)or(cur_cmd=kana)or(cur_cmd=other_kchar) then {|wchar_token|} |
| 1088 |
@y |
| 1089 |
ptex_revision_code, uptex_revision_code: do_nothing; |
| 1090 |
string_code, meaning_code: begin save_scanner_status:=scanner_status; |
| 1091 |
scanner_status:=normal; get_token; |
| 1092 |
if (cur_cmd>=kanji)and(cur_cmd<=modifier) then {|wchar_token|} |
| 1093 |
@z |
| 1094 |
|
| 1095 |
@x |
| 1096 |
ucs_code: begin cur_val:=fromUCS(cur_val); |
| 1097 |
if cur_val=0 then print_int(-1) else print_int(cur_val); end; |
| 1098 |
toucs_code: begin cur_val:=toUCS(cur_val); |
| 1099 |
if cur_val=0 then print_int(-1) else print_int(cur_val); end; |
| 1100 |
@y |
| 1101 |
ucs_code: if (isinternalUPTEX) then print_int(fromUCS(cur_val)) |
| 1102 |
else begin cur_val:=fromUCS(cur_val); |
| 1103 |
if cur_val=0 then print_int(-1) else print_int(cur_val); end; |
| 1104 |
toucs_code: if (isinternalUPTEX) then print_int(toUCS(cur_val)) |
| 1105 |
else begin cur_val:=toUCS(cur_val); |
| 1106 |
if cur_val=0 then print_int(-1) else print_int(cur_val); end; |
| 1107 |
@z |
| 1108 |
|
| 1109 |
@x |
| 1110 |
ptex_revision_code: print(pTeX_revision); |
| 1111 |
@y |
| 1112 |
ptex_revision_code: print(pTeX_revision); |
| 1113 |
uptex_revision_code: print(upTeX_revision); |
| 1114 |
@z |
| 1115 |
|
| 1116 |
@x |
| 1117 |
if (cur_cmd=kanji)or(cur_cmd=kana)or(cur_cmd=other_kchar) then |
| 1118 |
begin m:=cur_cmd; n:=cur_chr; |
| 1119 |
end |
| 1120 |
else if (cur_cmd>active_char)or(cur_chr>255) then |
| 1121 |
@y |
| 1122 |
if (cur_cmd>=kanji)and(cur_cmd<=modifier) then |
| 1123 |
begin m:=cur_cmd; n:=cur_chr; |
| 1124 |
end |
| 1125 |
else if (cur_cmd>active_char)or(cur_chr>=max_latin_val) then |
| 1126 |
@z |
| 1127 |
|
| 1128 |
@x |
| 1129 |
get_x_token_or_active_char; |
| 1130 |
if (cur_cmd=kanji)or(cur_cmd=kana)or(cur_cmd=other_kchar) then |
| 1131 |
begin cur_cmd:=cur_cmd; |
| 1132 |
end {dummy} |
| 1133 |
else if (cur_cmd>active_char)or(cur_chr>255) then |
| 1134 |
@y |
| 1135 |
get_x_token_or_active_char; |
| 1136 |
if (cur_cmd>=kanji)and(cur_cmd<=modifier) then |
| 1137 |
begin cur_cmd:=cur_cmd; |
| 1138 |
end {dummy} |
| 1139 |
else if (cur_cmd>active_char)or(cur_chr>=max_latin_val) then |
| 1140 |
@z |
| 1141 |
|
| 1142 |
@x |
| 1143 |
@p procedure scan_file_name; |
| 1144 |
label done; |
| 1145 |
var |
| 1146 |
@!save_warning_index: pointer; |
| 1147 |
begin |
| 1148 |
@y |
| 1149 |
@p procedure scan_file_name; |
| 1150 |
label done; |
| 1151 |
var |
| 1152 |
@!save_warning_index: pointer; |
| 1153 |
@!v,@!nn,@!jj: integer; |
| 1154 |
begin |
| 1155 |
@z |
| 1156 |
|
| 1157 |
@x |
| 1158 |
if (cur_cmd=kanji)or(cur_cmd=kana)or(cur_cmd=other_kchar) then {is kanji} |
| 1159 |
begin str_room(2); |
| 1160 |
append_char(@"100+Hi(cur_chr)); {kanji upper byte} |
| 1161 |
append_char(@"100+Lo(cur_chr)); {kanji lower byte} |
| 1162 |
end |
| 1163 |
else if (cur_cmd>other_char)or(cur_chr>255) then {not an alphabet} |
| 1164 |
@y |
| 1165 |
if (cur_cmd>=kanji)and(cur_cmd<=modifier) then {|wchar_token|} |
| 1166 |
begin |
| 1167 |
if (isinternalUPTEX) then begin |
| 1168 |
cur_chr:=toUCS(cur_chr); |
| 1169 |
nn:=UVSgetcodepointlength(cur_chr); |
| 1170 |
jj:=1; |
| 1171 |
while jj<=nn do begin |
| 1172 |
v:=UVSgetcodepointinsequence(cur_chr,jj); |
| 1173 |
if (v>0) then begin |
| 1174 |
str_room(4); |
| 1175 |
v:=UCStoUTF8(v); |
| 1176 |
if BYTE1(v)<>0 then append_char(@"100+BYTE1(v)); |
| 1177 |
if BYTE2(v)<>0 then append_char(@"100+BYTE2(v)); |
| 1178 |
if BYTE3(v)<>0 then append_char(@"100+BYTE3(v)); |
| 1179 |
append_char(@"100+BYTE4(v)); |
| 1180 |
end; |
| 1181 |
incr(jj); |
| 1182 |
end |
| 1183 |
end |
| 1184 |
else begin |
| 1185 |
str_room(4); {4 is maximum} |
| 1186 |
cur_chr:=toBUFF(cur_chr); |
| 1187 |
if BYTE1(cur_chr)<>0 then append_char(@"100+BYTE1(cur_chr)); |
| 1188 |
if BYTE2(cur_chr)<>0 then append_char(@"100+BYTE2(cur_chr)); |
| 1189 |
if BYTE3(cur_chr)<>0 then append_char(@"100+BYTE3(cur_chr)); |
| 1190 |
append_char(@"100+BYTE4(cur_chr)); |
| 1191 |
end; |
| 1192 |
end |
| 1193 |
else if (cur_cmd>other_char)or(cur_chr>=max_latin_val) then {not an alphabet} |
| 1194 |
@z |
| 1195 |
|
| 1196 |
@x |
| 1197 |
@d non_char==qi(256) {a |halfword| code that can't match a real character} |
| 1198 |
@y |
| 1199 |
@d non_char==qi(max_latin_val) {a code that can't match a real character} |
| 1200 |
@z |
| 1201 |
|
| 1202 |
@x |
| 1203 |
@!font_bc: ^eight_bits; |
| 1204 |
{beginning (smallest) character code} |
| 1205 |
@!font_ec: ^eight_bits; |
| 1206 |
{ending (largest) character code} |
| 1207 |
@y |
| 1208 |
@!font_bc: ^sixteen_bits; |
| 1209 |
{beginning (smallest) character code} |
| 1210 |
@!font_ec: ^sixteen_bits; |
| 1211 |
{ending (largest) character code} |
| 1212 |
@z |
| 1213 |
|
| 1214 |
@x |
| 1215 |
@d char_width_end(#)==#.b0].sc |
| 1216 |
@d char_width(#)==font_info[width_base[#]+char_width_end |
| 1217 |
@d char_exists(#)==(#.b0>min_quarterword) |
| 1218 |
@d char_italic_end(#)==(qo(#.b2)) div 4].sc |
| 1219 |
@d char_italic(#)==font_info[italic_base[#]+char_italic_end |
| 1220 |
@d height_depth(#)==qo(#.b1) |
| 1221 |
@d char_height_end(#)==(#) div 16].sc |
| 1222 |
@d char_height(#)==font_info[height_base[#]+char_height_end |
| 1223 |
@d char_depth_end(#)==(#) mod 16].sc |
| 1224 |
@d char_depth(#)==font_info[depth_base[#]+char_depth_end |
| 1225 |
@d char_tag(#)==((qo(#.b2)) mod 4) |
| 1226 |
@y |
| 1227 |
@d char_width_end(#)==#.b0].sc |
| 1228 |
@d char_width(#)==font_info[width_base[#]+char_width_end |
| 1229 |
@d char_exists(#)==(#.b0>min_quarterword) |
| 1230 |
@d char_italic_end(#)==(qo(#.b2)) div 256].sc |
| 1231 |
@d char_italic(#)==font_info[italic_base[#]+char_italic_end |
| 1232 |
@d height_depth(#)==qo(#.b1) |
| 1233 |
@d char_height_end(#)==(#) div 256].sc |
| 1234 |
@d char_height(#)==font_info[height_base[#]+char_height_end |
| 1235 |
@d char_depth_end(#)==(#) mod 256].sc |
| 1236 |
@d char_depth(#)==font_info[depth_base[#]+char_depth_end |
| 1237 |
@d char_tag(#)==((qo(#.b2)) mod 4) |
| 1238 |
@z |
| 1239 |
|
| 1240 |
@x |
| 1241 |
@!cx:KANJI_code; {kanji code} |
| 1242 |
@y |
| 1243 |
@!cx:KANJI_code; {kanji code} |
| 1244 |
@!ofm_flag:integer; |
| 1245 |
@!font_level,@!header_length:integer; |
| 1246 |
@!fn_dir:integer; |
| 1247 |
@!ncw,@!nlw,@!neew:integer; |
| 1248 |
@z |
| 1249 |
|
| 1250 |
@x |
| 1251 |
@!a,@!b,@!c,@!d:eight_bits; {byte variables} |
| 1252 |
@y |
| 1253 |
@!a,@!b,@!c,@!d:integer; {byte variables} |
| 1254 |
@z |
| 1255 |
|
| 1256 |
@x |
| 1257 |
if file_opened then print(" not loadable: Bad metric (TFM) file") |
| 1258 |
else if name_too_long then print(" not loadable: Metric (TFM) file name too long") |
| 1259 |
else print(" not loadable: Metric (TFM) file not found"); |
| 1260 |
@y |
| 1261 |
if file_opened then print(" not loadable: Bad metric (TFM/OFM) file") |
| 1262 |
else if name_too_long then print(" not loadable: Metric (TFM/OFM) file name too long") |
| 1263 |
else print(" not loadable: Metric (TFM/OFM) file not found"); |
| 1264 |
@z |
| 1265 |
|
| 1266 |
@x |
| 1267 |
pack_file_name(nom,aire,""); |
| 1268 |
if not b_open_in(tfm_file) then abort; |
| 1269 |
@y |
| 1270 |
pack_file_name(nom,aire,""); |
| 1271 |
if not ofm_open_in(tfm_file) then |
| 1272 |
if not b_open_in(tfm_file) then abort; |
| 1273 |
@z |
| 1274 |
|
| 1275 |
@x |
| 1276 |
@d read_sixteen(#)==begin #:=fbyte; |
| 1277 |
if #>127 then abort; |
| 1278 |
fget; #:=#*@'400+fbyte; |
| 1279 |
end |
| 1280 |
@d read_twentyfourx(#)==begin #:=fbyte; |
| 1281 |
fget; #:=#*@"100+fbyte; |
| 1282 |
fget; #:=#+fbyte*@"10000; |
| 1283 |
end |
| 1284 |
@d store_four_quarters(#)==begin fget; a:=fbyte; qw.b0:=qi(a); |
| 1285 |
fget; b:=fbyte; qw.b1:=qi(b); |
| 1286 |
fget; c:=fbyte; qw.b2:=qi(c); |
| 1287 |
fget; d:=fbyte; qw.b3:=qi(d); |
| 1288 |
#:=qw; |
| 1289 |
end |
| 1290 |
@y |
| 1291 |
@d read_sixteen(#)==begin #:=fbyte; |
| 1292 |
if #>127 then abort; |
| 1293 |
fget; #:=#*@'400+fbyte; |
| 1294 |
end |
| 1295 |
@d read_sixteen_unsigned(#)==begin #:=fbyte; |
| 1296 |
fget; #:=#*@'400+fbyte; |
| 1297 |
end |
| 1298 |
@d read_twentyfourx(#)==begin #:=fbyte; |
| 1299 |
fget; #:=#*@"100+fbyte; |
| 1300 |
fget; #:=#+fbyte*@"10000; |
| 1301 |
end |
| 1302 |
@d read_thirtytwo(#)==begin #:=fbyte; |
| 1303 |
if #>127 then abort; |
| 1304 |
fget; #:=#*@'400+fbyte; |
| 1305 |
fget; #:=#*@'400+fbyte; |
| 1306 |
fget; #:=#*@'400+fbyte; |
| 1307 |
end |
| 1308 |
@d store_four_quarters(#)==begin |
| 1309 |
if (ofm_flag<>0) then begin |
| 1310 |
fget; read_sixteen_unsigned(a); qw.b0:=a; |
| 1311 |
fget; read_sixteen_unsigned(b); qw.b1:=b; |
| 1312 |
fget; read_sixteen_unsigned(c); qw.b2:=c; |
| 1313 |
fget; read_sixteen_unsigned(d); qw.b3:=d; |
| 1314 |
#:=qw; |
| 1315 |
end |
| 1316 |
else begin |
| 1317 |
fget; a:=fbyte; qw.b0:=qi(a); |
| 1318 |
fget; b:=fbyte; qw.b1:=qi(b); |
| 1319 |
fget; c:=fbyte; qw.b2:=qi(c); |
| 1320 |
fget; d:=fbyte; qw.b3:=qi(d); |
| 1321 |
#:=qw; |
| 1322 |
end |
| 1323 |
end |
| 1324 |
@d store_character_info(#)==begin |
| 1325 |
if (ofm_flag<>0) then begin |
| 1326 |
fget; read_sixteen_unsigned(a); qw.b0:=a; |
| 1327 |
fget; read_sixteen_unsigned(b); qw.b1:=b; |
| 1328 |
fget; read_sixteen_unsigned(c); qw.b2:=c; |
| 1329 |
fget; read_sixteen_unsigned(d); qw.b3:=d; |
| 1330 |
#:=qw; |
| 1331 |
end |
| 1332 |
else begin |
| 1333 |
fget; a:=fbyte; qw.b0:=qi(a); |
| 1334 |
fget; b:=fbyte; |
| 1335 |
b:=(b div 16)*256 + (b mod 16); qw.b1:=b; |
| 1336 |
fget; c:=fbyte; |
| 1337 |
c:=(c div 4)*256 + (c mod 4); qw.b2:=c; |
| 1338 |
fget; d:=fbyte; qw.b3:=qi(d); |
| 1339 |
#:=qw; |
| 1340 |
end |
| 1341 |
end |
| 1342 |
@z |
| 1343 |
|
| 1344 |
@x |
| 1345 |
@ @<Read the {\.{TFM}} size fields@>= |
| 1346 |
begin read_sixteen(lf); |
| 1347 |
fget; read_sixteen(lh); |
| 1348 |
@y |
| 1349 |
@ @<Read the {\.{TFM}} size fields@>= |
| 1350 |
begin read_sixteen(lf); |
| 1351 |
fget; read_sixteen(lh); |
| 1352 |
ofm_flag:=0; |
| 1353 |
font_level:=-1; |
| 1354 |
ncw:=0; nlw:=0; neew:=0; |
| 1355 |
@z |
| 1356 |
|
| 1357 |
@x |
| 1358 |
else if lf=tate_jfm_id then |
| 1359 |
begin jfm_flag:=dir_tate; nt:=lh; |
| 1360 |
fget; read_sixteen(lf); |
| 1361 |
fget; read_sixteen(lh); |
| 1362 |
end |
| 1363 |
@y |
| 1364 |
else if lf=tate_jfm_id then |
| 1365 |
begin jfm_flag:=dir_tate; nt:=lh; |
| 1366 |
fget; read_sixteen(lf); |
| 1367 |
fget; read_sixteen(lh); |
| 1368 |
end |
| 1369 |
else if lf=0 then |
| 1370 |
begin ofm_flag:=1; |
| 1371 |
font_level:=lh; |
| 1372 |
jfm_flag:=dir_default; nt:=0; |
| 1373 |
if (font_level<>0) then abort; |
| 1374 |
fget; read_thirtytwo(lf); |
| 1375 |
fget; read_thirtytwo(lh); |
| 1376 |
end |
| 1377 |
@z |
| 1378 |
|
| 1379 |
@x |
| 1380 |
else begin jfm_flag:=dir_default; nt:=0; |
| 1381 |
end; |
| 1382 |
fget; read_sixteen(bc); |
| 1383 |
fget; read_sixteen(ec); |
| 1384 |
if (bc>ec+1)or(ec>255) then abort; |
| 1385 |
if bc>255 then {|bc=256| and |ec=255|} |
| 1386 |
begin bc:=1; ec:=0; |
| 1387 |
end; |
| 1388 |
fget; read_sixteen(nw); |
| 1389 |
fget; read_sixteen(nh); |
| 1390 |
fget; read_sixteen(nd); |
| 1391 |
fget; read_sixteen(ni); |
| 1392 |
fget; read_sixteen(nl); |
| 1393 |
fget; read_sixteen(nk); |
| 1394 |
fget; read_sixteen(ne); |
| 1395 |
fget; read_sixteen(np); |
| 1396 |
@y |
| 1397 |
else begin jfm_flag:=dir_default; nt:=0; |
| 1398 |
end; |
| 1399 |
if ofm_flag<>1 then begin |
| 1400 |
fget; read_sixteen(bc); |
| 1401 |
fget; read_sixteen(ec); |
| 1402 |
if (bc>ec+1)or(ec>255) then abort; |
| 1403 |
if bc>255 then {|bc=256| and |ec=255|} |
| 1404 |
begin bc:=1; ec:=0; |
| 1405 |
end; |
| 1406 |
fget; read_sixteen(nw); |
| 1407 |
fget; read_sixteen(nh); |
| 1408 |
fget; read_sixteen(nd); |
| 1409 |
fget; read_sixteen(ni); |
| 1410 |
fget; read_sixteen(nl); |
| 1411 |
fget; read_sixteen(nk); |
| 1412 |
fget; read_sixteen(ne); |
| 1413 |
fget; read_sixteen(np); |
| 1414 |
end |
| 1415 |
else begin |
| 1416 |
fget; read_thirtytwo(bc); |
| 1417 |
fget; read_thirtytwo(ec); |
| 1418 |
if (bc>ec+1)or(ec>65535) then abort; |
| 1419 |
if bc>65535 then {|bc=65536| and |ec=65535|} |
| 1420 |
begin bc:=1; ec:=0; |
| 1421 |
end; |
| 1422 |
fget; read_thirtytwo(nw); |
| 1423 |
fget; read_thirtytwo(nh); |
| 1424 |
fget; read_thirtytwo(nd); |
| 1425 |
fget; read_thirtytwo(ni); |
| 1426 |
fget; read_thirtytwo(nl); |
| 1427 |
fget; read_thirtytwo(nk); |
| 1428 |
fget; read_thirtytwo(ne); |
| 1429 |
fget; read_thirtytwo(np); |
| 1430 |
fget; read_thirtytwo(fn_dir); |
| 1431 |
nlw:=2*nl; |
| 1432 |
neew:=2*ne; |
| 1433 |
if font_level=0 then begin |
| 1434 |
header_length:=14; |
| 1435 |
ncw:=2*(ec-bc+1); |
| 1436 |
end |
| 1437 |
else begin |
| 1438 |
abort; |
| 1439 |
end; |
| 1440 |
end; |
| 1441 |
if ofm_flag<>0 then |
| 1442 |
begin if lf<>header_length+lh+ncw+nw+nh+nd+ni+nlw+nk+neew+np |
| 1443 |
then abort; |
| 1444 |
end |
| 1445 |
else |
| 1446 |
@z |
| 1447 |
|
| 1448 |
@x |
| 1449 |
@<Use size fields to allocate font information@>= |
| 1450 |
if jfm_flag<>dir_default then |
| 1451 |
@y |
| 1452 |
@<Use size fields to allocate font information@>= |
| 1453 |
if ofm_flag<>0 then begin |
| 1454 |
if font_level=0 then |
| 1455 |
lf:=lf-14-lh-(ec-bc+1)-nl-ne |
| 1456 |
else |
| 1457 |
abort; |
| 1458 |
end |
| 1459 |
else |
| 1460 |
if jfm_flag<>dir_default then |
| 1461 |
@z |
| 1462 |
|
| 1463 |
@x |
| 1464 |
font_enc[f]:=jfm_enc; if jfm_flag=dir_default then font_enc[f]:=0; |
| 1465 |
font_num_ext[f]:=nt; |
| 1466 |
ctype_base[f]:=fmem_ptr; |
| 1467 |
char_base[f]:=ctype_base[f]+nt-bc; |
| 1468 |
width_base[f]:=char_base[f]+ec+1; |
| 1469 |
@y |
| 1470 |
font_enc[f]:=0; |
| 1471 |
if (jfm_flag=dir_default)and(jfm_enc>=enc_t1) then font_enc[f]:=jfm_enc; |
| 1472 |
if (jfm_flag<>dir_default)and(jfm_enc<=enc_ucs) then font_enc[f]:=jfm_enc; |
| 1473 |
font_num_ext[f]:=nt; |
| 1474 |
ctype_base[f]:=fmem_ptr; |
| 1475 |
char_base[f]:=ctype_base[f]+nt-bc; |
| 1476 |
width_base[f]:=char_base[f]+ec+1; |
| 1477 |
@z |
| 1478 |
|
| 1479 |
@x |
| 1480 |
store_four_quarters(font_check[f]); |
| 1481 |
@y |
| 1482 |
begin |
| 1483 |
fget; a:=fbyte; qw.b0:=qi(a); |
| 1484 |
fget; b:=fbyte; qw.b1:=qi(b); |
| 1485 |
fget; c:=fbyte; qw.b2:=qi(c); |
| 1486 |
fget; d:=fbyte; qw.b3:=qi(d); |
| 1487 |
font_check[f]:=qw; |
| 1488 |
end; |
| 1489 |
@z |
| 1490 |
|
| 1491 |
@x |
| 1492 |
@ @<Read character data@>= |
| 1493 |
if jfm_flag<>dir_default then |
| 1494 |
for k:=ctype_base[f] to ctype_base[f]+nt-1 do |
| 1495 |
begin |
| 1496 |
fget; read_twentyfourx(cx); |
| 1497 |
if jfm_enc=enc_ucs then {Unicode TFM} |
| 1498 |
font_info[k].hh.rh:=toDVI(fromUCS(cx)) |
| 1499 |
else if jfm_enc=enc_jis then {JIS-encoded TFM} |
| 1500 |
font_info[k].hh.rh:=toDVI(fromJIS(cx)) |
| 1501 |
else |
| 1502 |
font_info[k].hh.rh:=tokanji(cx); {|kchar_code|} |
| 1503 |
fget; cx:=fbyte; |
| 1504 |
font_info[k].hh.lhfield:=tonum(cx); {|kchar_type|} |
| 1505 |
end; |
| 1506 |
for k:=char_base[f]+bc to width_base[f]-1 do |
| 1507 |
begin store_four_quarters(font_info[k].qqqq); |
| 1508 |
if (a>=nw)or(b div @'20>=nh)or(b mod @'20>=nd)or |
| 1509 |
(c div 4>=ni) then abort; |
| 1510 |
case c mod 4 of |
| 1511 |
lig_tag: if d>=nl then abort; |
| 1512 |
ext_tag: if d>=ne then abort; |
| 1513 |
list_tag: @<Check for charlist cycle@>; |
| 1514 |
othercases do_nothing {|no_tag|} |
| 1515 |
endcases; |
| 1516 |
end |
| 1517 |
@y |
| 1518 |
@ @<Read character data@>= |
| 1519 |
if ofm_flag<>0 then begin |
| 1520 |
if font_level=1 then begin |
| 1521 |
abort; |
| 1522 |
end; |
| 1523 |
end |
| 1524 |
else |
| 1525 |
if jfm_flag<>dir_default then |
| 1526 |
for k:=ctype_base[f] to ctype_base[f]+nt-1 do |
| 1527 |
begin |
| 1528 |
fget; read_twentyfourx(cx); |
| 1529 |
if jfm_enc=enc_ucs then {Unicode TFM} |
| 1530 |
font_info[k].hh.rh:=toDVI(fromUCS(cx)) |
| 1531 |
else if jfm_enc=enc_jis then {JIS-encoded TFM} |
| 1532 |
font_info[k].hh.rh:=toDVI(fromJIS(cx)) |
| 1533 |
else |
| 1534 |
font_info[k].hh.rh:=tokanji(cx); {|kchar_code|} |
| 1535 |
fget; cx:=fbyte; |
| 1536 |
font_info[k].hh.lhfield:=tonum(cx); {|kchar_type|} |
| 1537 |
end; |
| 1538 |
k:=char_base[f]+bc; |
| 1539 |
while k<=width_base[f]-1 do |
| 1540 |
begin store_character_info(font_info[k].qqqq); |
| 1541 |
if (a>=nw)or((b div 256)>=nh)or((b mod 256)>=nd)or |
| 1542 |
((c div 256)>=ni) then abort; |
| 1543 |
case c mod 4 of |
| 1544 |
lig_tag: if d>=nl then abort; |
| 1545 |
ext_tag: if d>=ne then abort; |
| 1546 |
list_tag: @<Check for charlist cycle@>; |
| 1547 |
othercases do_nothing {|no_tag|} |
| 1548 |
endcases; |
| 1549 |
incr(k); |
| 1550 |
if font_level=1 then begin |
| 1551 |
abort; |
| 1552 |
end; |
| 1553 |
end |
| 1554 |
@z |
| 1555 |
|
| 1556 |
@x |
| 1557 |
@<Read ligature/kern program@>= |
| 1558 |
bch_label:=@'77777; bchar:=256; |
| 1559 |
@y |
| 1560 |
@<Read ligature/kern program@>= |
| 1561 |
bch_label:=@'77777; bchar:=max_latin_val; |
| 1562 |
@z |
| 1563 |
|
| 1564 |
@x |
| 1565 |
@p procedure char_warning(@!f:internal_font_number;@!c:eight_bits); |
| 1566 |
@y |
| 1567 |
@p procedure char_warning(@!f:internal_font_number;@!c:sixteen_bits); |
| 1568 |
@z |
| 1569 |
|
| 1570 |
@x |
| 1571 |
if (c<" ")or(c>"~") then |
| 1572 |
begin print_char("^"); print_char("^"); |
| 1573 |
if c<64 then print_char(c+64) |
| 1574 |
else if c<128 then print_char(c-64) |
| 1575 |
else begin print_lc_hex(c div 16); print_lc_hex(c mod 16); end |
| 1576 |
end |
| 1577 |
@y |
| 1578 |
if (c<" ")or(c>"~") then begin |
| 1579 |
print_char("^"); print_char("^"); |
| 1580 |
if c<64 then print_char(c+64) |
| 1581 |
else if c<128 then print_char(c-64) |
| 1582 |
else if c<256 then begin |
| 1583 |
print_lc_hex(c div 16); print_lc_hex(c mod 16); end |
| 1584 |
else begin print_char("^"); print_char("^"); |
| 1585 |
print_lc_hex(c div 4096); print_lc_hex((c mod 4096) div 256); |
| 1586 |
print_lc_hex((c mod 256) div 16); print_lc_hex(c mod 16); end |
| 1587 |
end |
| 1588 |
@z |
| 1589 |
|
| 1590 |
@x |
| 1591 |
@p function new_character(@!f:internal_font_number;@!c:eight_bits):pointer; |
| 1592 |
label exit; |
| 1593 |
var p:pointer; {newly allocated node} |
| 1594 |
@!ec:quarterword; {effective character of |c|} |
| 1595 |
begin ec:=effective_char(false,f,qi(c)); |
| 1596 |
if font_bc[f]<=qo(ec) then if font_ec[f]>=qo(ec) then |
| 1597 |
if char_exists(orig_char_info(f)(ec)) then {N.B.: not |char_info|} |
| 1598 |
begin p:=get_avail; font(p):=f; character(p):=qi(c); |
| 1599 |
new_character:=p; return; |
| 1600 |
end; |
| 1601 |
char_warning(f,c); |
| 1602 |
new_character:=null; |
| 1603 |
exit:end; |
| 1604 |
@y |
| 1605 |
@p function new_character(@!f:internal_font_number;@!c:sixteen_bits):pointer; |
| 1606 |
label exit; |
| 1607 |
var p:pointer; {newly allocated node} |
| 1608 |
@!ec,cc:quarterword; {effective character of |c|} |
| 1609 |
begin cc:=c; |
| 1610 |
c:=ptencucsto8bitcode(font_enc[f],c); |
| 1611 |
ec:=effective_char(false,f,qi(c)); |
| 1612 |
if font_bc[f]<=qo(ec) then if font_ec[f]>=qo(ec) then |
| 1613 |
if char_exists(orig_char_info(f)(ec)) then {N.B.: not |char_info|} |
| 1614 |
begin p:=get_avail; font(p):=f; character(p):=qi(c); |
| 1615 |
new_character:=p; return; |
| 1616 |
end; |
| 1617 |
char_warning(f,cc); |
| 1618 |
new_character:=null; |
| 1619 |
exit:end; |
| 1620 |
@z |
| 1621 |
|
| 1622 |
@x |
| 1623 |
@d set2=129 {typeset a character and move right} |
| 1624 |
@y |
| 1625 |
@d set2=129 {typeset a character and move right} |
| 1626 |
@d set3=130 {typeset a character and move right} |
| 1627 |
@d set4=131 {typeset a character and move right} |
| 1628 |
@z |
| 1629 |
|
| 1630 |
@x |
| 1631 |
if font_dir[f]=dir_default then |
| 1632 |
begin chain:=false; |
| 1633 |
if font_ec[f]>=qo(c) then if font_bc[f]<=qo(c) then |
| 1634 |
if char_exists(orig_char_info(f)(c)) then {N.B.: not |char_info|} |
| 1635 |
begin if c>=qi(128) then dvi_out(set1); |
| 1636 |
dvi_out(qo(c));@/ |
| 1637 |
@y |
| 1638 |
if font_dir[f]=dir_default then |
| 1639 |
begin chain:=false; |
| 1640 |
c:=ptencucsto8bitcode(font_enc[f],c); |
| 1641 |
if font_ec[f]>=qo(c) then if font_bc[f]<=qo(c) then |
| 1642 |
if char_exists(orig_char_info(f)(c)) then {N.B.: not |char_info|} |
| 1643 |
begin if c>=qi(@"100) then begin |
| 1644 |
dvi_out(set2); dvi_out(Hi(c)); dvi_out(Lo(c)); |
| 1645 |
end |
| 1646 |
else begin if c>=qi(128) then dvi_out(set1); |
| 1647 |
dvi_out(qo(c));@/ |
| 1648 |
end; |
| 1649 |
@z |
| 1650 |
|
| 1651 |
@x |
| 1652 |
jc:=KANJI(info(p)); |
| 1653 |
@y |
| 1654 |
jc:=ktokentochr(info(p)); |
| 1655 |
@z |
| 1656 |
|
| 1657 |
@x |
| 1658 |
dvi_out(set2); dvi_out(Hi(jc)); dvi_out(Lo(jc)); |
| 1659 |
@y |
| 1660 |
if (jc<@"10000) then begin |
| 1661 |
dvi_out(set2); |
| 1662 |
end else if (jc<@"1000000) then begin |
| 1663 |
dvi_out(set3); dvi_out(BYTE2(jc)); |
| 1664 |
end else begin |
| 1665 |
dvi_out(set4); dvi_out(BYTE1(jc)); dvi_out(BYTE2(jc)); |
| 1666 |
end; |
| 1667 |
dvi_out(BYTE3(jc)); dvi_out(BYTE4(jc)); |
| 1668 |
@z |
| 1669 |
|
| 1670 |
@x |
| 1671 |
@!hd:eight_bits; {height and depth indices for a character} |
| 1672 |
@y |
| 1673 |
@!hd:sixteen_bits; {height and depth indices for a character} |
| 1674 |
@!cx:integer; |
| 1675 |
@z |
| 1676 |
|
| 1677 |
@x |
| 1678 |
@<Incorporate character dimensions into the dimensions of the hbox...@>= |
| 1679 |
begin f:=font(p); i:=char_info(f)(character(p)); hd:=height_depth(i); |
| 1680 |
@y |
| 1681 |
@<Incorporate character dimensions into the dimensions of the hbox...@>= |
| 1682 |
begin f:=font(p); cx:=ptencucsto8bitcode(font_enc[f],character(p)); |
| 1683 |
i:=char_info(f)(cx); hd:=height_depth(i); |
| 1684 |
@z |
| 1685 |
|
| 1686 |
@x |
| 1687 |
@!hd: eight_bits; {height-depth byte} |
| 1688 |
@y |
| 1689 |
@!hd: sixteen_bits; {height-depth byte} |
| 1690 |
@z |
| 1691 |
|
| 1692 |
@x |
| 1693 |
@!hd:eight_bits; {|height_depth| byte} |
| 1694 |
@y |
| 1695 |
@!hd:sixteen_bits; {|height_depth| byte} |
| 1696 |
@z |
| 1697 |
|
| 1698 |
@x |
| 1699 |
@!hd:eight_bits; {|height_depth| byte} |
| 1700 |
@y |
| 1701 |
@!hd:sixteen_bits; {|height_depth| byte} |
| 1702 |
@z |
| 1703 |
|
| 1704 |
@x |
| 1705 |
@d span_code=256 {distinct from any character} |
| 1706 |
@d cr_code=257 {distinct from |span_code| and from any character} |
| 1707 |
@y |
| 1708 |
@d span_code=max_cjk_val {distinct from any character} |
| 1709 |
@d cr_code=max_cjk_val+1 {distinct from |span_code| and from any character} |
| 1710 |
@z |
| 1711 |
|
| 1712 |
@x |
| 1713 |
@!cc:ASCII_code; |
| 1714 |
@y |
| 1715 |
@!cc:sixteen_bits; |
| 1716 |
@z |
| 1717 |
|
| 1718 |
@x |
| 1719 |
ligature_node: begin f:=font(lig_char(cur_p)); |
| 1720 |
act_width:=act_width+char_width(f)(char_info(f)(character(lig_char(cur_p)))); |
| 1721 |
@y |
| 1722 |
ligature_node: begin f:=font(lig_char(cur_p)); |
| 1723 |
act_width:=act_width+char_width(f)(char_info(f)(ptencucsto8bitcode(font_enc[f],character(lig_char(cur_p))))); |
| 1724 |
@z |
| 1725 |
|
| 1726 |
@x |
| 1727 |
repeat f:=post_f; cc:=character(cur_p); |
| 1728 |
act_width:=act_width+char_width(f)(orig_char_info(f)(cc)); |
| 1729 |
@y |
| 1730 |
repeat f:=post_f; |
| 1731 |
cc:=ptencucsto8bitcode(font_enc[f],character(cur_p)); |
| 1732 |
act_width:=act_width+char_width(f)(orig_char_info(f)(cc)); |
| 1733 |
@z |
| 1734 |
|
| 1735 |
@x hyphen |
| 1736 |
@!hc:array[0..65] of 0..256; {word to be hyphenated} |
| 1737 |
@!hn:0..64; {the number of positions occupied in |hc|; |
| 1738 |
not always a |small_number|} |
| 1739 |
@!ha,@!hb:pointer; {nodes |ha..hb| should be replaced by the hyphenated result} |
| 1740 |
@!hf:internal_font_number; {font number of the letters in |hc|} |
| 1741 |
@!hu:array[0..63] of 0..256; {like |hc|, before conversion to lowercase} |
| 1742 |
@!hyf_char:integer; {hyphen character of the relevant font} |
| 1743 |
@!cur_lang,@!init_cur_lang:ASCII_code; {current hyphenation table of interest} |
| 1744 |
@!l_hyf,@!r_hyf,@!init_l_hyf,@!init_r_hyf:integer; {limits on fragment sizes} |
| 1745 |
@!hyf_bchar:halfword; {boundary character after $c_n$} |
| 1746 |
@y |
| 1747 |
@!hc:array[0..65] of 0..max_latin_val; {word to be hyphenated} |
| 1748 |
@!hn:0..64; {the number of positions occupied in |hc|; |
| 1749 |
not always a |small_number|} |
| 1750 |
@!ha,@!hb:pointer; {nodes |ha..hb| should be replaced by the hyphenated result} |
| 1751 |
@!hf:internal_font_number; {font number of the letters in |hc|} |
| 1752 |
@!hu:array[0..63] of 0..max_latin_val; {like |hc|, before conversion to lowercase} |
| 1753 |
@!hyf_char:integer; {hyphen character of the relevant font} |
| 1754 |
@!cur_lang,@!init_cur_lang:ASCII_code; {current hyphenation table of interest} |
| 1755 |
@!l_hyf,@!r_hyf,@!init_l_hyf,@!init_r_hyf:integer; {limits on fragment sizes} |
| 1756 |
@!hyf_bchar:halfword; {boundary character after $c_n$} |
| 1757 |
@!max_hyph_char:integer; |
| 1758 |
|
| 1759 |
@ @<Set initial values of key variables@>= |
| 1760 |
max_hyph_char:=max_latin_val-1; |
| 1761 |
@z |
| 1762 |
|
| 1763 |
@x |
| 1764 |
@<Local variables for line...@>= |
| 1765 |
@!j:small_number; {an index into |hc| or |hu|} |
| 1766 |
@!c:0..255; {character being considered for hyphenation} |
| 1767 |
@y |
| 1768 |
@<Local variables for line...@>= |
| 1769 |
@!j:small_number; {an index into |hc| or |hu|} |
| 1770 |
@!c:sixteen_bits; {character being considered for hyphenation} |
| 1771 |
@z |
| 1772 |
|
| 1773 |
@x |
| 1774 |
if hyf_char>255 then goto done1; |
| 1775 |
@y |
| 1776 |
if hyf_char>=max_latin_val then goto done1; |
| 1777 |
@z |
| 1778 |
|
| 1779 |
@x |
| 1780 |
hn:=0; |
| 1781 |
loop@+ begin if is_char_node(s) then |
| 1782 |
begin if font(s)<>hf then goto done3; |
| 1783 |
hyf_bchar:=character(s); c:=qo(hyf_bchar); |
| 1784 |
if lc_code(c)=0 then goto done3; |
| 1785 |
if hn=63 then goto done3; |
| 1786 |
hb:=s; incr(hn); hu[hn]:=c; hc[hn]:=lc_code(c); hyf_bchar:=non_char; |
| 1787 |
@y |
| 1788 |
hn:=0; |
| 1789 |
loop@+ begin if is_char_node(s) then |
| 1790 |
begin if font(s)<>hf then goto done3; |
| 1791 |
hyf_bchar:=character(s); c:=qo(hyf_bchar); |
| 1792 |
if lc_code(c)=0 then goto done3; |
| 1793 |
if lc_code(c)>max_hyph_char then goto done3; |
| 1794 |
if hn=63 then goto done3; |
| 1795 |
hb:=s; incr(hn); hu[hn]:=c; hc[hn]:=lc_code(c); hyf_bchar:=non_char; |
| 1796 |
@z |
| 1797 |
|
| 1798 |
@x |
| 1799 |
while q>null do |
| 1800 |
begin c:=qo(character(q)); |
| 1801 |
if lc_code(c)=0 then goto done3; |
| 1802 |
if j=63 then goto done3; |
| 1803 |
incr(j); hu[j]:=c; hc[j]:=lc_code(c);@/ |
| 1804 |
q:=link(q); |
| 1805 |
end; |
| 1806 |
@y |
| 1807 |
while q>null do |
| 1808 |
begin c:=qo(character(q)); |
| 1809 |
if lc_code(c)=0 then goto done3; |
| 1810 |
if lc_code(c)>max_hyph_char then goto done3; |
| 1811 |
if j=63 then goto done3; |
| 1812 |
incr(j); hu[j]:=c; hc[j]:=lc_code(c);@/ |
| 1813 |
q:=link(q); |
| 1814 |
end; |
| 1815 |
@z |
| 1816 |
|
| 1817 |
@x |
| 1818 |
begin hu[0]:=256; init_lig:=false; |
| 1819 |
@y |
| 1820 |
begin hu[0]:=non_char; init_lig:=false; |
| 1821 |
@z |
| 1822 |
|
| 1823 |
@x |
| 1824 |
found2: s:=ha; j:=0; hu[0]:=256; init_lig:=false; init_list:=null; |
| 1825 |
@y |
| 1826 |
found2: s:=ha; j:=0; hu[0]:=non_char; init_lig:=false; init_list:=null; |
| 1827 |
@z |
| 1828 |
|
| 1829 |
@x |
| 1830 |
getting the input $x_j\ldots x_n$ from the |hu| array. If $x_j=256$, |
| 1831 |
we consider $x_j$ to be an implicit left boundary character; in this |
| 1832 |
case |j| must be strictly less than~|n|. There is a |
| 1833 |
parameter |bchar|, which is either 256 or an implicit right boundary character |
| 1834 |
@y |
| 1835 |
getting the input $x_j\ldots x_n$ from the |hu| array. If $x_j=|non_char|$, |
| 1836 |
we consider $x_j$ to be an implicit left boundary character; in this |
| 1837 |
case |j| must be strictly less than~|n|. There is a |
| 1838 |
parameter |bchar|, which is either |non_char| |
| 1839 |
or an implicit right boundary character |
| 1840 |
@z |
| 1841 |
|
| 1842 |
@x |
| 1843 |
else begin q:=char_info(hf)(cur_l); |
| 1844 |
@y |
| 1845 |
else begin q:=char_info(hf)(ptencucsto8bitcode(font_enc[hf],cur_l)); |
| 1846 |
@z |
| 1847 |
|
| 1848 |
@x |
| 1849 |
@<Local variables for hyph...@>= |
| 1850 |
@!major_tail,@!minor_tail:pointer; {the end of lists in the main and |
| 1851 |
discretionary branches being reconstructed} |
| 1852 |
@!c:ASCII_code; {character temporarily replaced by a hyphen} |
| 1853 |
@y |
| 1854 |
@<Local variables for hyph...@>= |
| 1855 |
@!major_tail,@!minor_tail:pointer; {the end of lists in the main and |
| 1856 |
discretionary branches being reconstructed} |
| 1857 |
@!c:sixteen_bits; {character temporarily replaced by a hyphen} |
| 1858 |
@z |
| 1859 |
|
| 1860 |
@x |
| 1861 |
begin decr(l); c:=hu[l]; c_loc:=l; hu[l]:=256; |
| 1862 |
@y |
| 1863 |
begin decr(l); c:=hu[l]; c_loc:=l; hu[l]:=non_char; |
| 1864 |
@z |
| 1865 |
|
| 1866 |
@x |
| 1867 |
hyphenation algorithm is quite short. In the following code we set |hc[hn+2]| |
| 1868 |
to the impossible value 256, in order to guarantee that |hc[hn+3]| will |
| 1869 |
@y |
| 1870 |
hyphenation algorithm is quite short. In the following code we set |hc[hn+2]| to |
| 1871 |
the impossible value |non_char|, in order to guarantee that |hc[hn+3]| will |
| 1872 |
@z |
| 1873 |
|
| 1874 |
@x |
| 1875 |
hc[0]:=0; hc[hn+1]:=0; hc[hn+2]:=256; {insert delimiters} |
| 1876 |
@y |
| 1877 |
hc[0]:=0; hc[hn+1]:=0; hc[hn+2]:=non_char; {insert delimiters} |
| 1878 |
@z |
| 1879 |
|
| 1880 |
@x |
| 1881 |
@t\hskip10pt@>@!trie_min:array[ASCII_code] of trie_pointer; |
| 1882 |
@y |
| 1883 |
@t\hskip10pt@>@!trie_min:array[0..max_latin_val] of trie_pointer; |
| 1884 |
@z |
| 1885 |
|
| 1886 |
@x |
| 1887 |
for p:=0 to 255 do trie_min[p]:=p+1; |
| 1888 |
@y |
| 1889 |
for p:=0 to max_latin_val-1 do trie_min[p]:=p+1; |
| 1890 |
@z |
| 1891 |
|
| 1892 |
@x first_fit |
| 1893 |
@!ll:1..256; {upper limit of |trie_min| updating} |
| 1894 |
@y |
| 1895 |
@!ll:1..max_latin_val; {upper limit of |trie_min| updating} |
| 1896 |
@z |
| 1897 |
|
| 1898 |
@x |
| 1899 |
@<Ensure that |trie_max>=h+256|@>; |
| 1900 |
@y |
| 1901 |
@<Ensure that |trie_max>=h+max_hyph_char|@>; |
| 1902 |
@z |
| 1903 |
|
| 1904 |
@x |
| 1905 |
@ By making sure that |trie_max| is at least |h+256|, we can be sure that |
| 1906 |
|trie_max>z|, since |h=z-c|. It follows that location |trie_max| will |
| 1907 |
never be occupied in |trie|, and we will have |trie_max>=trie_link(z)|. |
| 1908 |
|
| 1909 |
@<Ensure that |trie_max>=h+256|@>= |
| 1910 |
if trie_max<h+256 then |
| 1911 |
begin if trie_size<=h+256 then overflow("pattern memory",trie_size); |
| 1912 |
@y |
| 1913 |
@ By making sure that |trie_max| is at least |h+max_hyph_char|, |
| 1914 |
we can be sure that |
| 1915 |
|trie_max>z|, since |h=z-c|. It follows that location |trie_max| will |
| 1916 |
never be occupied in |trie|, and we will have |trie_max>=trie_link(z)|. |
| 1917 |
|
| 1918 |
@<Ensure that |trie_max>=h+max_hyph_char|@>= |
| 1919 |
if trie_max<h+max_hyph_char then |
| 1920 |
begin if trie_size<=h+max_hyph_char then overflow("pattern memory",trie_size); |
| 1921 |
@z |
| 1922 |
|
| 1923 |
@x |
| 1924 |
until trie_max=h+256; |
| 1925 |
@y |
| 1926 |
until trie_max=h+max_hyph_char; |
| 1927 |
@z |
| 1928 |
|
| 1929 |
@x |
| 1930 |
if l<256 then |
| 1931 |
begin if z<256 then ll:=z @+else ll:=256; |
| 1932 |
@y |
| 1933 |
if l<max_hyph_char then |
| 1934 |
begin if z<max_hyph_char then ll:=z @+else ll:=max_hyph_char; |
| 1935 |
@z |
| 1936 |
|
| 1937 |
@x |
| 1938 |
begin for r:=0 to 256 do clear_trie; |
| 1939 |
trie_max:=256; |
| 1940 |
end |
| 1941 |
@y |
| 1942 |
begin for r:=0 to max_hyph_char do clear_trie; |
| 1943 |
trie_max:=max_hyph_char; |
| 1944 |
end |
| 1945 |
@z |
| 1946 |
|
| 1947 |
@x |
| 1948 |
if cur_chr=0 then |
| 1949 |
begin print_err("Nonletter"); |
| 1950 |
@.Nonletter@> |
| 1951 |
help1("(See Appendix H.)"); error; |
| 1952 |
end; |
| 1953 |
end; |
| 1954 |
@y |
| 1955 |
if cur_chr=0 then |
| 1956 |
begin print_err("Nonletter"); |
| 1957 |
@.Nonletter@> |
| 1958 |
help1("(See Appendix H.)"); error; |
| 1959 |
end; |
| 1960 |
end; |
| 1961 |
if cur_chr>max_hyph_char then max_hyph_char:=cur_chr; |
| 1962 |
@z |
| 1963 |
|
| 1964 |
@x |
| 1965 |
begin @<Get ready to compress the trie@>; |
| 1966 |
@y |
| 1967 |
begin |
| 1968 |
incr(max_hyph_char); |
| 1969 |
@<Get ready to compress the trie@>; |
| 1970 |
@z |
| 1971 |
|
| 1972 |
@x |
| 1973 |
var@!t:integer; {general-purpose temporary variable} |
| 1974 |
@!cx:KANJI_code; {kanji character} |
| 1975 |
@y |
| 1976 |
var@!t:integer; {general-purpose temporary variable} |
| 1977 |
@!cx:KANJI_code; {kanji character} |
| 1978 |
@!cy:sixteen_bits; |
| 1979 |
@z |
| 1980 |
|
| 1981 |
@x |
| 1982 |
hmode+kanji,hmode+kana,hmode+other_kchar: goto main_loop_j; |
| 1983 |
hmode+char_given: |
| 1984 |
if is_char_ascii(cur_chr) then goto main_loop else goto main_loop_j; |
| 1985 |
hmode+char_num: begin scan_char_num; cur_chr:=cur_val; |
| 1986 |
if is_char_ascii(cur_chr) then goto main_loop else goto main_loop_j; |
| 1987 |
end; |
| 1988 |
hmode+no_boundary: begin get_x_token; |
| 1989 |
if (cur_cmd=letter)or(cur_cmd=other_char)or |
| 1990 |
(cur_cmd=kanji)or(cur_cmd=kana)or(cur_cmd=other_kchar)or |
| 1991 |
(cur_cmd=char_given)or(cur_cmd=char_num) then cancel_boundary:=true; |
| 1992 |
@y |
| 1993 |
hmode+kanji,hmode+kana,hmode+other_kchar,hmode+hangul,hmode+modifier: goto main_loop_j; |
| 1994 |
hmode+char_given: |
| 1995 |
if check_echar_range(cur_chr) then goto main_loop |
| 1996 |
else begin cur_cmd:=kcat_code(kcatcodekey(cur_chr)); |
| 1997 |
if (cur_cmd<=not_cjk) then cur_cmd:=other_kchar; |
| 1998 |
goto main_loop_j; end; |
| 1999 |
hmode+kchar_given: |
| 2000 |
begin cur_cmd:=kcat_code(kcatcodekey(cur_chr)); goto main_loop_j; end; |
| 2001 |
hmode+char_num: begin scan_char_num; cur_chr:=cur_val; |
| 2002 |
if check_echar_range(cur_chr) then goto main_loop |
| 2003 |
else begin cur_cmd:=kcat_code(kcatcodekey(cur_chr)); |
| 2004 |
if (cur_cmd<=not_cjk) then cur_cmd:=other_kchar; |
| 2005 |
goto main_loop_j; end; |
| 2006 |
end; |
| 2007 |
hmode+kchar_num: begin scan_char_num; cur_chr:=cur_val; |
| 2008 |
cur_cmd:=kcat_code(kcatcodekey(cur_chr)); |
| 2009 |
goto main_loop_j; |
| 2010 |
end; |
| 2011 |
hmode+no_boundary: begin get_x_token; |
| 2012 |
if (cur_cmd=letter)or(cur_cmd=other_char)or |
| 2013 |
((cur_cmd>=kanji)and(cur_cmd<=modifier))or |
| 2014 |
(cur_cmd=char_given)or(cur_cmd=char_num)or |
| 2015 |
(cur_cmd=kchar_given)or(cur_cmd=kchar_num) then cancel_boundary:=true; |
| 2016 |
@z |
| 2017 |
|
| 2018 |
@x |
| 2019 |
main_loop_move+2: |
| 2020 |
if(qo(effective_char(false,main_f,qi(cur_chr)))>font_ec[main_f])or |
| 2021 |
(qo(effective_char(false,main_f,qi(cur_chr)))<font_bc[main_f]) then |
| 2022 |
begin char_warning(main_f,cur_chr); free_avail(lig_stack); goto big_switch; |
| 2023 |
end; |
| 2024 |
main_i:=effective_char_info(main_f,cur_l); |
| 2025 |
@y |
| 2026 |
main_loop_move+2: |
| 2027 |
cur_chr:=ptencucsto8bitcode(font_enc[main_f],cur_chr); |
| 2028 |
if(qo(effective_char(false,main_f,qi(cur_chr)))>font_ec[main_f])or |
| 2029 |
(qo(effective_char(false,main_f,qi(cur_chr)))<font_bc[main_f]) then |
| 2030 |
begin char_warning(main_f,cur_chr); free_avail(lig_stack); goto big_switch; |
| 2031 |
end; |
| 2032 |
if not ligature_present then cur_l:=ptencucsto8bitcode(font_enc[main_f],cur_l); |
| 2033 |
main_i:=effective_char_info(main_f,cur_l); |
| 2034 |
@z |
| 2035 |
|
| 2036 |
@x |
| 2037 |
if cur_cmd=letter then goto main_loop_lookahead+1; |
| 2038 |
if (cur_cmd=kanji)or(cur_cmd=kana)or(cur_cmd=other_kchar) then |
| 2039 |
@<goto |main_lig_loop|@>; |
| 2040 |
if cur_cmd=other_char then goto main_loop_lookahead+1; |
| 2041 |
if cur_cmd=char_given then |
| 2042 |
begin if is_char_ascii(cur_chr) then goto main_loop_lookahead+1 |
| 2043 |
else @<goto |main_lig_loop|@>; |
| 2044 |
end; |
| 2045 |
x_token; {now expand and set |cur_cmd|, |cur_chr|, |cur_tok|} |
| 2046 |
if cur_cmd=letter then goto main_loop_lookahead+1; |
| 2047 |
if (cur_cmd=kanji)or(cur_cmd=kana)or(cur_cmd=other_kchar) then |
| 2048 |
@<goto |main_lig_loop|@>; |
| 2049 |
if cur_cmd=other_char then goto main_loop_lookahead+1; |
| 2050 |
if cur_cmd=char_given then |
| 2051 |
begin if is_char_ascii(cur_chr) then goto main_loop_lookahead+1 |
| 2052 |
else @<goto |main_lig_loop|@>; |
| 2053 |
end; |
| 2054 |
if cur_cmd=char_num then |
| 2055 |
begin scan_char_num; cur_chr:=cur_val; |
| 2056 |
if is_char_ascii(cur_chr) then goto main_loop_lookahead+1 |
| 2057 |
else @<goto |main_lig_loop|@>; |
| 2058 |
end; |
| 2059 |
@y |
| 2060 |
if cur_cmd=letter then goto main_loop_lookahead+1; |
| 2061 |
if (cur_cmd>=kanji)and(cur_cmd<=modifier) then |
| 2062 |
@<goto |main_lig_loop|@>; |
| 2063 |
if cur_cmd=other_char then goto main_loop_lookahead+1; |
| 2064 |
if cur_cmd=char_given then |
| 2065 |
begin if check_echar_range(cur_chr) then goto main_loop_lookahead+1 |
| 2066 |
else begin cur_cmd:=kcat_code(kcatcodekey(cur_chr)); @<goto |main_lig_loop|@>; end; |
| 2067 |
end; |
| 2068 |
if cur_cmd=kchar_given then |
| 2069 |
begin cur_cmd:=kcat_code(kcatcodekey(cur_chr)); @<goto |main_lig_loop|@>; end; |
| 2070 |
x_token; {now expand and set |cur_cmd|, |cur_chr|, |cur_tok|} |
| 2071 |
if cur_cmd=letter then goto main_loop_lookahead+1; |
| 2072 |
if (cur_cmd>=kanji)and(cur_cmd<=modifier) then |
| 2073 |
@<goto |main_lig_loop|@>; |
| 2074 |
if cur_cmd=other_char then goto main_loop_lookahead+1; |
| 2075 |
if cur_cmd=char_given then |
| 2076 |
begin if check_echar_range(cur_chr) then goto main_loop_lookahead+1 |
| 2077 |
else begin cur_cmd:=kcat_code(kcatcodekey(cur_chr)); @<goto |main_lig_loop|@>; end; |
| 2078 |
end; |
| 2079 |
if cur_cmd=kchar_given then |
| 2080 |
begin cur_cmd:=kcat_code(kcatcodekey(cur_chr)); @<goto |main_lig_loop|@>; end; |
| 2081 |
if cur_cmd=char_num then |
| 2082 |
begin scan_char_num; cur_chr:=cur_val; |
| 2083 |
if check_echar_range(cur_chr) then goto main_loop_lookahead+1 |
| 2084 |
else begin cur_cmd:=kcat_code(kcatcodekey(cur_chr)); @<goto |main_lig_loop|@>; end; |
| 2085 |
end; |
| 2086 |
if cur_cmd=kchar_num then |
| 2087 |
begin scan_char_num; cur_chr:=cur_val; |
| 2088 |
cur_cmd:=kcat_code(kcatcodekey(cur_chr)); |
| 2089 |
@<goto |main_lig_loop|@>; |
| 2090 |
end; |
| 2091 |
@z |
| 2092 |
|
| 2093 |
@x |
| 2094 |
main_lig_loop+1:main_j:=font_info[main_k].qqqq; |
| 2095 |
main_lig_loop+2:if next_char(main_j)=cur_r then |
| 2096 |
if skip_byte(main_j)<=stop_flag then |
| 2097 |
@<Do ligature or kern command, returning to |main_lig_loop| |
| 2098 |
or |main_loop_wrapup| or |main_loop_move|@>; |
| 2099 |
@y |
| 2100 |
main_lig_loop+1:main_j:=font_info[main_k].qqqq; |
| 2101 |
main_lig_loop+2: |
| 2102 |
cy:=ptencucsto8bitcode(font_enc[main_f],cur_r); |
| 2103 |
if next_char(main_j)=cy then |
| 2104 |
if skip_byte(main_j)<=stop_flag then |
| 2105 |
@<Do ligature or kern command, returning to |main_lig_loop| |
| 2106 |
or |main_loop_wrapup| or |main_loop_move|@>; |
| 2107 |
@z |
| 2108 |
|
| 2109 |
@x |
| 2110 |
vmode+letter,vmode+other_char,vmode+char_num,vmode+char_given, |
| 2111 |
vmode+math_shift,vmode+un_hbox,vmode+vrule, |
| 2112 |
vmode+accent,vmode+discretionary,vmode+hskip,vmode+valign, |
| 2113 |
vmode+kanji,vmode+kana,vmode+other_kchar, |
| 2114 |
@y |
| 2115 |
vmode+letter,vmode+other_char,vmode+char_num,vmode+char_given, |
| 2116 |
vmode+kchar_num,vmode+kchar_given, |
| 2117 |
vmode+math_shift,vmode+un_hbox,vmode+vrule, |
| 2118 |
vmode+accent,vmode+discretionary,vmode+hskip,vmode+valign, |
| 2119 |
vmode+kanji,vmode+kana,vmode+other_kchar,vmode+hangul,vmode+modifier, |
| 2120 |
@z |
| 2121 |
|
| 2122 |
|
| 2123 |
@x |
| 2124 |
begin c:=hyphen_char[cur_font]; |
| 2125 |
if c>=0 then if c<256 then pre_break(tail):=new_character(cur_font,c); |
| 2126 |
end |
| 2127 |
@y |
| 2128 |
begin c:=hyphen_char[cur_font]; |
| 2129 |
if c>=0 then if c<max_latin_val then pre_break(tail):=new_character(cur_font,c); |
| 2130 |
end |
| 2131 |
@z |
| 2132 |
|
| 2133 |
@x |
| 2134 |
if not is_char_ascii(cur_val) then |
| 2135 |
begin KANJI(cx):=cur_val; |
| 2136 |
if direction=dir_tate then f:=cur_tfont else f:=cur_jfont; |
| 2137 |
p:=new_character(f,get_jfm_pos(KANJI(cx),f)); |
| 2138 |
if p<>null then |
| 2139 |
begin |
| 2140 |
link(p):=get_avail; info(link(p)):=KANJI(cx); |
| 2141 |
end; |
| 2142 |
@y |
| 2143 |
if check_echar_range(cur_val)=0 then |
| 2144 |
begin KANJI(cx):=cur_val; |
| 2145 |
if direction=dir_tate then f:=cur_tfont else f:=cur_jfont; |
| 2146 |
p:=new_character(f,get_jfm_pos(KANJI(cx),f)); |
| 2147 |
if p<>null then |
| 2148 |
begin |
| 2149 |
link(p):=get_avail; |
| 2150 |
if (kcat_code(kcatcodekey(cx))=kanji)and(cx>=max_cjk_val) then |
| 2151 |
info(link(p)):=KANJI(cx) + kanji_ivs*max_cjk_val |
| 2152 |
else |
| 2153 |
info(link(p)):=KANJI(cx) + kcat_code(kcatcodekey(cx))*max_cjk_val; |
| 2154 |
end; |
| 2155 |
@z |
| 2156 |
|
| 2157 |
@x |
| 2158 |
if (cur_cmd=letter)or(cur_cmd=other_char) then |
| 2159 |
q:=new_character(f,cur_chr) |
| 2160 |
else if (cur_cmd=kanji)or(cur_cmd=kana)or(cur_cmd=other_kchar) then |
| 2161 |
begin if direction=dir_tate then f:=cur_tfont else f:=cur_jfont; |
| 2162 |
cx:=cur_chr; |
| 2163 |
end |
| 2164 |
else if cur_cmd=char_given then |
| 2165 |
if is_char_ascii(cur_chr) then q:=new_character(f,cur_chr) |
| 2166 |
else begin |
| 2167 |
if direction=dir_tate then f:=cur_tfont else f:=cur_jfont; |
| 2168 |
KANJI(cx):=cur_chr |
| 2169 |
end |
| 2170 |
else if cur_cmd=char_num then |
| 2171 |
begin scan_char_num; |
| 2172 |
if is_char_ascii(cur_val) then q:=new_character(f,cur_val) |
| 2173 |
else begin |
| 2174 |
if direction=dir_tate then f:=cur_tfont else f:=cur_jfont; |
| 2175 |
KANJI(cx):=cur_val |
| 2176 |
end |
| 2177 |
end |
| 2178 |
@y |
| 2179 |
if (cur_cmd=letter)or(cur_cmd=other_char) then |
| 2180 |
q:=new_character(f,cur_chr) |
| 2181 |
else if (cur_cmd>=kanji)and(cur_cmd<=modifier) then |
| 2182 |
begin if direction=dir_tate then f:=cur_tfont else f:=cur_jfont; |
| 2183 |
cx:=cur_chr; |
| 2184 |
end |
| 2185 |
else if cur_cmd=char_given then |
| 2186 |
if check_echar_range(cur_chr) then q:=new_character(f,cur_chr) |
| 2187 |
else begin |
| 2188 |
if direction=dir_tate then f:=cur_tfont else f:=cur_jfont; |
| 2189 |
KANJI(cx):=cur_chr; cur_cmd:=kcat_code(kcatcodekey(cx)); |
| 2190 |
end |
| 2191 |
else if cur_cmd=char_num then |
| 2192 |
begin scan_char_num; |
| 2193 |
if check_echar_range(cur_val) then q:=new_character(f,cur_val) |
| 2194 |
else begin |
| 2195 |
if direction=dir_tate then f:=cur_tfont else f:=cur_jfont; |
| 2196 |
KANJI(cx):=cur_val; cur_cmd:=kcat_code(kcatcodekey(cx)); |
| 2197 |
end |
| 2198 |
end |
| 2199 |
else if cur_cmd=kchar_given then |
| 2200 |
begin |
| 2201 |
if direction=dir_tate then f:=cur_tfont else f:=cur_jfont; |
| 2202 |
KANJI(cx):=cur_chr; cur_cmd:=kcat_code(kcatcodekey(cx)); |
| 2203 |
end |
| 2204 |
else if cur_cmd=kchar_num then |
| 2205 |
begin scan_char_num; |
| 2206 |
if direction=dir_tate then f:=cur_tfont else f:=cur_jfont; |
| 2207 |
KANJI(cx):=cur_val; cur_cmd:=kcat_code(kcatcodekey(cx)); |
| 2208 |
end |
| 2209 |
@z |
| 2210 |
|
| 2211 |
@x |
| 2212 |
begin q:=new_character(f,get_jfm_pos(KANJI(cx),f)); |
| 2213 |
link(q):=get_avail; info(link(q)):=KANJI(cx); last_jchr:=q; |
| 2214 |
@y |
| 2215 |
begin q:=new_character(f,get_jfm_pos(KANJI(cx),f)); |
| 2216 |
link(q):=get_avail; |
| 2217 |
if (kcat_code(kcatcodekey(cx))=kanji)and(cx>=max_cjk_val) then |
| 2218 |
info(link(q)):=KANJI(cx) + kanji_ivs*max_cjk_val |
| 2219 |
else |
| 2220 |
info(link(q)):=KANJI(cx) + kcat_code(kcatcodekey(cx))*max_cjk_val; |
| 2221 |
last_jchr:=q; |
| 2222 |
@z |
| 2223 |
|
| 2224 |
@x |
| 2225 |
letter,other_char,char_given: |
| 2226 |
if is_char_ascii(cur_chr) then begin |
| 2227 |
@y |
| 2228 |
letter,other_char,char_given: |
| 2229 |
if check_echar_range(cur_chr) then begin |
| 2230 |
@z |
| 2231 |
|
| 2232 |
@x |
| 2233 |
KANJI(cx):=cur_chr; |
| 2234 |
kanji,kana,other_kchar: cx:=cur_chr; |
| 2235 |
char_num: begin scan_char_num; cur_chr:=cur_val; cur_cmd:=char_given; |
| 2236 |
goto reswitch; |
| 2237 |
end; |
| 2238 |
@y |
| 2239 |
KANJI(cx):=cur_chr; |
| 2240 |
kanji,kana,other_kchar,hangul,modifier: cx:=cur_chr; |
| 2241 |
kchar_given: |
| 2242 |
KANJI(cx):=cur_chr; |
| 2243 |
char_num: begin scan_char_num; cur_chr:=cur_val; cur_cmd:=char_given; |
| 2244 |
goto reswitch; |
| 2245 |
end; |
| 2246 |
kchar_num: begin scan_char_num; cur_chr:=cur_val; cur_cmd:=kchar_given; |
| 2247 |
goto reswitch; |
| 2248 |
end; |
| 2249 |
@z |
| 2250 |
|
| 2251 |
@x |
| 2252 |
math_type(p):=math_jchar; fam(p):=cur_jfam; character(p):=qi(0); |
| 2253 |
math_kcode(p-1):=KANJI(cx); |
| 2254 |
@y |
| 2255 |
math_type(p):=math_jchar; fam(p):=cur_jfam; character(p):=qi(0); |
| 2256 |
if (kcat_code(kcatcodekey(cx))=kanji)and(cx>=max_cjk_val) then |
| 2257 |
math_kcode(p-1):=KANJI(cx) + kanji_ivs*max_cjk_val |
| 2258 |
else |
| 2259 |
math_kcode(p-1):=KANJI(cx) + kcat_code(kcatcodekey(cx))*max_cjk_val; |
| 2260 |
@z |
| 2261 |
|
| 2262 |
@x |
| 2263 |
mmode+letter,mmode+other_char,mmode+char_given: |
| 2264 |
if is_char_ascii(cur_chr) then |
| 2265 |
set_math_char(ho(math_code(cur_chr))) |
| 2266 |
else set_math_kchar(cur_chr); |
| 2267 |
mmode+kanji,mmode+kana,mmode+other_kchar: begin |
| 2268 |
cx:=cur_chr; set_math_kchar(KANJI(cx)); |
| 2269 |
end; |
| 2270 |
mmode+char_num: begin scan_char_num; cur_chr:=cur_val; |
| 2271 |
if is_char_ascii(cur_chr) then |
| 2272 |
set_math_char(ho(math_code(cur_chr))) |
| 2273 |
else set_math_kchar(cur_chr); |
| 2274 |
end; |
| 2275 |
@y |
| 2276 |
mmode+letter,mmode+other_char,mmode+char_given: |
| 2277 |
if check_echar_range(cur_chr) then |
| 2278 |
set_math_char(ho(math_code(cur_chr))) |
| 2279 |
else set_math_kchar(cur_chr); |
| 2280 |
mmode+kanji,mmode+kana,mmode+other_kchar,mmode+hangul,mmode+modifier: begin |
| 2281 |
cx:=cur_chr; set_math_kchar(KANJI(cx)); |
| 2282 |
end; |
| 2283 |
mmode+char_num: begin scan_char_num; cur_chr:=cur_val; |
| 2284 |
if check_echar_range(cur_chr) then |
| 2285 |
set_math_char(ho(math_code(cur_chr))) |
| 2286 |
else set_math_kchar(cur_chr); |
| 2287 |
end; |
| 2288 |
mmode+kchar_given: |
| 2289 |
set_math_kchar(cur_chr); |
| 2290 |
mmode+kchar_num: begin scan_char_num; cur_chr:=cur_val; |
| 2291 |
set_math_kchar(cur_chr); |
| 2292 |
end; |
| 2293 |
@z |
| 2294 |
|
| 2295 |
@x |
| 2296 |
any_mode(assign_inhibit_xsp_code), |
| 2297 |
any_mode(set_auto_spacing), |
| 2298 |
@y |
| 2299 |
any_mode(assign_inhibit_xsp_code), |
| 2300 |
any_mode(set_auto_spacing), |
| 2301 |
any_mode(set_enable_cjk_token), |
| 2302 |
@z |
| 2303 |
|
| 2304 |
@x l.23666 - upTeX |
| 2305 |
@d char_sub_def_code=7 {|shorthand_def| for \.{\\charsubdef}} |
| 2306 |
|
| 2307 |
@<Put each...@>= |
| 2308 |
primitive("chardef",shorthand_def,char_def_code);@/ |
| 2309 |
@!@:char_def_}{\.{\\chardef} primitive@> |
| 2310 |
@y |
| 2311 |
@d char_sub_def_code=7 {|shorthand_def| for \.{\\charsubdef}} |
| 2312 |
@d kchar_def_code=char_sub_def_code+1 {|shorthand_def| for \.{\\kchardef}} |
| 2313 |
|
| 2314 |
@<Put each...@>= |
| 2315 |
primitive("chardef",shorthand_def,char_def_code);@/ |
| 2316 |
@!@:char_def_}{\.{\\chardef} primitive@> |
| 2317 |
primitive("kchardef",shorthand_def,kchar_def_code);@/ |
| 2318 |
@!@:kchar_def_}{\.{\\kchardef} primitive@> |
| 2319 |
@z |
| 2320 |
|
| 2321 |
@x |
| 2322 |
shorthand_def: case chr_code of |
| 2323 |
char_def_code: print_esc("chardef"); |
| 2324 |
math_char_def_code: print_esc("mathchardef"); |
| 2325 |
@y |
| 2326 |
shorthand_def: case chr_code of |
| 2327 |
char_def_code: print_esc("chardef"); |
| 2328 |
kchar_def_code: print_esc("kchardef"); |
| 2329 |
math_char_def_code: print_esc("mathchardef"); |
| 2330 |
@z |
| 2331 |
|
| 2332 |
@x l.23698 - upTeX |
| 2333 |
char_given: begin print_esc("char"); print_hex(chr_code); |
| 2334 |
end; |
| 2335 |
@y |
| 2336 |
char_given: begin print_esc("char"); print_hex(chr_code); |
| 2337 |
end; |
| 2338 |
kchar_given: begin print_esc("kchar"); print_hex(chr_code); |
| 2339 |
end; |
| 2340 |
@z |
| 2341 |
|
| 2342 |
@x l.23729 - upTeX |
| 2343 |
char_def_code: begin scan_char_num; define(p,char_given,cur_val); |
| 2344 |
end; |
| 2345 |
@y |
| 2346 |
char_def_code: begin scan_char_num; define(p,char_given,cur_val); |
| 2347 |
end; |
| 2348 |
kchar_def_code: begin scan_char_num; define(p,kchar_given,cur_val); |
| 2349 |
end; |
| 2350 |
@z |
| 2351 |
|
| 2352 |
@x |
| 2353 |
if p=kcat_code_base then |
| 2354 |
begin scan_char_num; p:=p+kcatcodekey(cur_val) end |
| 2355 |
else begin scan_ascii_num; p:=p+cur_val; end; |
| 2356 |
@y |
| 2357 |
if p=kcat_code_base then |
| 2358 |
begin scan_char_num; p:=p+kcatcodekey(cur_val); |
| 2359 |
if cur_val>=max_latin_val then m:=not_cjk; end |
| 2360 |
else if p<math_code_base then |
| 2361 |
begin scan_latin_num; p:=p+cur_val; end |
| 2362 |
else begin scan_ascii_num; p:=p+cur_val; end; |
| 2363 |
@z |
| 2364 |
|
| 2365 |
@x |
| 2366 |
@ @<Let |m| be the minimal...@>= |
| 2367 |
if cur_chr=kcat_code_base then m:=kanji else m:=0 |
| 2368 |
|
| 2369 |
@ @<Let |n| be the largest...@>= |
| 2370 |
if cur_chr=cat_code_base then n:=invalid_char {1byte |max_char_code|} |
| 2371 |
else if cur_chr=kcat_code_base then n:=max_char_code |
| 2372 |
@y |
| 2373 |
@ @<Let |m| be the minimal...@>= |
| 2374 |
if cur_chr=kcat_code_base then m:=latin_ucs else m:=0 |
| 2375 |
|
| 2376 |
@ @<Let |n| be the largest...@>= |
| 2377 |
if cur_chr=cat_code_base then n:=invalid_char {1byte |max_char_code|} |
| 2378 |
else if cur_chr=kcat_code_base then n:=max_char_code |
| 2379 |
else if cur_chr<math_code_base then n:=max_latin_val |
| 2380 |
@z |
| 2381 |
|
| 2382 |
@x |
| 2383 |
procedure shift_case; |
| 2384 |
var b:pointer; {|lc_code_base| or |uc_code_base|} |
| 2385 |
@!p:pointer; {runs through the token list} |
| 2386 |
@!t:halfword; {token} |
| 2387 |
@!c:eight_bits; {character code} |
| 2388 |
@y |
| 2389 |
procedure shift_case; |
| 2390 |
var b:pointer; {|lc_code_base| or |uc_code_base|} |
| 2391 |
@!p:pointer; {runs through the token list} |
| 2392 |
@!t:halfword; {token} |
| 2393 |
@!c:sixteen_bits; {character code} |
| 2394 |
@z |
| 2395 |
|
| 2396 |
@x |
| 2397 |
|cs_token_flag+active_base| is a multiple of~256. |
| 2398 |
@y |
| 2399 |
|cs_token_flag+active_base| is a multiple of~|max_char_val|. |
| 2400 |
@z |
| 2401 |
|
| 2402 |
@x |
| 2403 |
@<Change the case of the token in |p|, if a change is appropriate@>= |
| 2404 |
t:=info(p); |
| 2405 |
if (t<cs_token_flag+single_base)and(not check_kanji(t)) then |
| 2406 |
begin c:=t mod 256; |
| 2407 |
@y |
| 2408 |
@<Change the case of the token in |p|, if a change is appropriate@>= |
| 2409 |
t:=info(p); |
| 2410 |
if (t<cs_token_flag+single_base)and(check_kanji(t)<2) then |
| 2411 |
begin c:=t mod max_char_val; |
| 2412 |
@z |
| 2413 |
|
| 2414 |
@x |
| 2415 |
font_bc:=xmalloc_array(eight_bits, font_max); |
| 2416 |
font_ec:=xmalloc_array(eight_bits, font_max); |
| 2417 |
@y |
| 2418 |
font_bc:=xmalloc_array(sixteen_bits, font_max); |
| 2419 |
font_ec:=xmalloc_array(sixteen_bits, font_max); |
| 2420 |
@z |
| 2421 |
|
| 2422 |
@x |
| 2423 |
font_bc:=xmalloc_array(eight_bits, font_max); |
| 2424 |
font_ec:=xmalloc_array(eight_bits, font_max); |
| 2425 |
@y |
| 2426 |
font_bc:=xmalloc_array(sixteen_bits, font_max); |
| 2427 |
font_ec:=xmalloc_array(sixteen_bits, font_max); |
| 2428 |
@z |
| 2429 |
|
| 2430 |
@x |
| 2431 |
@ @<Scan the font encoding specification@>= |
| 2432 |
begin jfm_enc:=0; |
| 2433 |
if scan_keyword_noexpand("in") then |
| 2434 |
if scan_keyword_noexpand("jis") then jfm_enc:=enc_jis |
| 2435 |
else if scan_keyword_noexpand("ucs") then jfm_enc:=enc_ucs |
| 2436 |
else begin |
| 2437 |
print_err("Unknown TFM encoding"); |
| 2438 |
@.Unknown TFM encoding@> |
| 2439 |
@y |
| 2440 |
@ @<Scan the font encoding specification@>= |
| 2441 |
begin jfm_enc:=0; |
| 2442 |
if scan_keyword_noexpand("in") then |
| 2443 |
if scan_keyword_noexpand("jis") then jfm_enc:=enc_jis |
| 2444 |
else if scan_keyword_noexpand("ucs") then jfm_enc:=enc_ucs |
| 2445 |
else if scan_keyword_noexpand("t1") then jfm_enc:=enc_t1 |
| 2446 |
else if scan_keyword_noexpand("ts1") then jfm_enc:=enc_ts1 |
| 2447 |
else if scan_keyword_noexpand("ly1") then jfm_enc:=enc_ly1 |
| 2448 |
else if scan_keyword_noexpand("t5") then jfm_enc:=enc_t5 |
| 2449 |
else if scan_keyword_noexpand("l7x") then jfm_enc:=enc_l7x |
| 2450 |
else if scan_keyword_noexpand("t2a") then jfm_enc:=enc_t2a |
| 2451 |
else if scan_keyword_noexpand("t2b") then jfm_enc:=enc_t2b |
| 2452 |
else if scan_keyword_noexpand("t2c") then jfm_enc:=enc_t2c |
| 2453 |
else if scan_keyword_noexpand("lgr") then jfm_enc:=enc_lgr |
| 2454 |
else begin |
| 2455 |
print_err("Unknown TFM encoding"); |
| 2456 |
@.Unknown TFM encoding@> |
| 2457 |
@z |
| 2458 |
|
| 2459 |
@x |
| 2460 |
@!t: eight_bits; |
| 2461 |
@y |
| 2462 |
@!t: sixteen_bits; |
| 2463 |
@z |
| 2464 |
|
| 2465 |
@x |
| 2466 |
@d set_auto_xspacing_code=3 |
| 2467 |
@y |
| 2468 |
@d set_auto_xspacing_code=3 |
| 2469 |
@d reset_enable_cjk_token_code=0 |
| 2470 |
@d set_enable_cjk_token_code=1 |
| 2471 |
@d set_force_cjk_token_code=2 |
| 2472 |
@z |
| 2473 |
|
| 2474 |
@x |
| 2475 |
@!@:no_auto_xspacing_}{\.{\\noautoxspacing} primitive@> |
| 2476 |
@y |
| 2477 |
@!@:no_auto_xspacing_}{\.{\\noautoxspacing} primitive@> |
| 2478 |
primitive("enablecjktoken",set_enable_cjk_token,reset_enable_cjk_token_code); |
| 2479 |
@!@:enable_cjk_token_}{\.{\\enablecjktoken} primitive@> |
| 2480 |
primitive("disablecjktoken",set_enable_cjk_token,set_enable_cjk_token_code); |
| 2481 |
@!@:disable_cjk_token_}{\.{\\disablecjktoken} primitive@> |
| 2482 |
primitive("forcecjktoken",set_enable_cjk_token,set_force_cjk_token_code); |
| 2483 |
@!@:force_cjk_token_}{\.{\\forcecjktoken} primitive@> |
| 2484 |
@z |
| 2485 |
|
| 2486 |
@x |
| 2487 |
if (chr_code mod 2)=0 then print_esc("noauto") else print_esc("auto"); |
| 2488 |
if chr_code<2 then print("spacing") else print("xspacing"); |
| 2489 |
end; |
| 2490 |
@y |
| 2491 |
if (chr_code mod 2)=0 then print_esc("noauto") else print_esc("auto"); |
| 2492 |
if chr_code<2 then print("spacing") else print("xspacing"); |
| 2493 |
end; |
| 2494 |
set_enable_cjk_token:begin |
| 2495 |
if chr_code=0 then print_esc("enable") |
| 2496 |
else if chr_code=1 then print_esc("disable") else print_esc("force"); |
| 2497 |
print("cjktoken"); |
| 2498 |
end; |
| 2499 |
@z |
| 2500 |
|
| 2501 |
@x |
| 2502 |
else begin p:=auto_xspacing_code; cur_chr:=(cur_chr mod 2); end; |
| 2503 |
define(p,data,cur_chr); |
| 2504 |
end; |
| 2505 |
@y |
| 2506 |
else begin p:=auto_xspacing_code; cur_chr:=(cur_chr mod 2); end; |
| 2507 |
define(p,data,cur_chr); |
| 2508 |
end; |
| 2509 |
set_enable_cjk_token: define(enable_cjk_token_code,data,cur_chr); |
| 2510 |
@z |
| 2511 |
|
| 2512 |
@x |
| 2513 |
cx:KANJI_code; {temporary register for KANJI character} |
| 2514 |
ax:ASCII_code; {temporary register for ASCII character} |
| 2515 |
@y |
| 2516 |
cx:KANJI_code; {temporary register for KANJI character} |
| 2517 |
ax:sixteen_bits; {temporary register for ASCII character} |
| 2518 |
@z |
| 2519 |
|
| 2520 |
@x |
| 2521 |
@ @<Insert a space around the character |p|@>= |
| 2522 |
if font_dir[font(p)]<>dir_default then |
| 2523 |
begin KANJI(cx):=info(link(p)); |
| 2524 |
@y |
| 2525 |
@ @<Insert a space around the character |p|@>= |
| 2526 |
if font_dir[font(p)]<>dir_default then |
| 2527 |
begin KANJI(cx):=ktokentochr(info(link(p))); |
| 2528 |
@z |
| 2529 |
|
| 2530 |
@x |
| 2531 |
else if font_dir[font(first_char)]<>dir_default then |
| 2532 |
begin KANJI(cx):=info(link(first_char)); |
| 2533 |
@y |
| 2534 |
else if font_dir[font(first_char)]<>dir_default then |
| 2535 |
begin KANJI(cx):=ktokentochr(info(link(first_char))); |
| 2536 |
@z |
| 2537 |
|
| 2538 |
@x |
| 2539 |
else if font_dir[font(last_char)]<>dir_default then |
| 2540 |
begin insert_skip:=after_wchar; KANJI(cx):=info(link(last_char)); |
| 2541 |
@y |
| 2542 |
else if font_dir[font(last_char)]<>dir_default then |
| 2543 |
begin insert_skip:=after_wchar; |
| 2544 |
KANJI(cx):=ktokentochr(info(link(last_char))); |
| 2545 |
@z |
| 2546 |
|
| 2547 |
@x |
| 2548 |
begin if is_char_node(link(p)) then |
| 2549 |
begin q:=p; p:=link(p); |
| 2550 |
if font_dir[font(p)]<>dir_default then |
| 2551 |
begin KANJI(cx):=info(link(p)); |
| 2552 |
@y |
| 2553 |
begin if is_char_node(link(p)) then |
| 2554 |
begin q:=p; p:=link(p); |
| 2555 |
if font_dir[font(p)]<>dir_default then |
| 2556 |
begin KANJI(cx):=ktokentochr(info(link(p))); |
| 2557 |
@z |
| 2558 |
|
| 2559 |
@x |
| 2560 |
begin KANJI(cx):=info(link(p)); i:=kcat_code(kcatcodekey(cx)); k:=0; |
| 2561 |
if (i=kanji)or(i=kana) then begin t:=q; s:=p; end; |
| 2562 |
@y |
| 2563 |
begin KANJI(cx):=ktokentochr(info(link(p))); |
| 2564 |
i:=ktokentocmd(info(link(p))); k:=0; |
| 2565 |
if (i=kanji)or(i=kana)or(i=hangul)or(i=modifier) then begin t:=q; s:=p; end; |
| 2566 |
@z |
| 2567 |
|
| 2568 |
@x |
| 2569 |
begin if not disp_called then |
| 2570 |
begin prev_node:=tail; tail_append(get_node(small_node_size)); |
| 2571 |
type(tail):=disp_node; disp_dimen(tail):=0; disp_called:=true |
| 2572 |
end; |
| 2573 |
fast_get_avail(main_p); font(main_p):=main_f; character(main_p):=cur_l; |
| 2574 |
link(tail):=main_p; tail:=main_p; last_jchr:=tail; |
| 2575 |
fast_get_avail(main_p); info(main_p):=KANJI(cur_chr); |
| 2576 |
@y |
| 2577 |
begin if (cur_cmd=modifier) then begin |
| 2578 |
KANJI(cx):=info(main_p) mod max_cjk_val; |
| 2579 |
if (UVScombinecode(cx,cur_chr)>0) then begin |
| 2580 |
cx:=UVScombinecode(cx,cur_chr); |
| 2581 |
if (kcat_code(kcatcodekey(KANJI(cx)))=kanji)and(cx>=max_cjk_val) then |
| 2582 |
info(main_p):=KANJI(cx)+kanji_ivs*max_cjk_val |
| 2583 |
else |
| 2584 |
info(main_p):=KANJI(cx)+kcat_code(kcatcodekey(KANJI(cx)))*max_cjk_val; |
| 2585 |
ins_kp:=false; |
| 2586 |
goto again_2 |
| 2587 |
end |
| 2588 |
else if ((info(main_p) div max_cjk_val)=0 and (cur_q>0)) then begin |
| 2589 |
KANJI(cx):=info(cur_q) mod max_cjk_val; |
| 2590 |
kp:=get_kinsoku_pos(cx,cur_pos); |
| 2591 |
if (UVScombinecode(cx,cur_chr)>0 and (kp<>no_entry) |
| 2592 |
and (kinsoku_penalty(kp)<>0) |
| 2593 |
and (kinsoku_type(kp)=pre_break_penalty_code)) then begin |
| 2594 |
cx:=UVScombinecode(cx,cur_chr); |
| 2595 |
if (kcat_code(kcatcodekey(KANJI(cx)))=kanji)and(cx>=max_cjk_val) then |
| 2596 |
info(cur_q):=KANJI(cx)+kanji_ivs*max_cjk_val |
| 2597 |
else |
| 2598 |
info(cur_q):=KANJI(cx)+kcat_code(kcatcodekey(KANJI(cx)))*max_cjk_val; |
| 2599 |
ins_kp:=false; |
| 2600 |
goto again_2 |
| 2601 |
end |
| 2602 |
end |
| 2603 |
end; |
| 2604 |
if not disp_called then |
| 2605 |
begin prev_node:=tail; tail_append(get_node(small_node_size)); |
| 2606 |
type(tail):=disp_node; disp_dimen(tail):=0; disp_called:=true |
| 2607 |
end; |
| 2608 |
fast_get_avail(main_p); font(main_p):=main_f; character(main_p):=cur_l; |
| 2609 |
link(tail):=main_p; tail:=main_p; last_jchr:=tail; |
| 2610 |
fast_get_avail(main_p); |
| 2611 |
if (cur_cmd=kanji)and(cur_chr>=max_cjk_val) then |
| 2612 |
info(main_p):=KANJI(cur_chr)+kanji_ivs*max_cjk_val |
| 2613 |
else if (cur_cmd>=kanji)and(cur_cmd<=modifier) then |
| 2614 |
info(main_p):=KANJI(cur_chr)+cur_cmd*max_cjk_val |
| 2615 |
else if cur_cmd=not_cjk then |
| 2616 |
info(main_p):=KANJI(cur_chr)+other_kchar*max_cjk_val |
| 2617 |
else if cur_cmd=latin_ucs then |
| 2618 |
info(main_p):=KANJI(cur_chr)+cat_code(cur_chr)*max_cjk_val |
| 2619 |
else { Does this case occur? } |
| 2620 |
info(main_p):=KANJI(cur_chr)+kcat_code(kcatcodekey(KANJI(cur_chr)))*max_cjk_val; |
| 2621 |
@z |
| 2622 |
|
| 2623 |
@x |
| 2624 |
main_i:=orig_char_info(main_f)(cur_l); |
| 2625 |
case cur_cmd of |
| 2626 |
kanji,kana,other_kchar: begin |
| 2627 |
@y |
| 2628 |
main_i:=orig_char_info(main_f)(cur_l); |
| 2629 |
case cur_cmd of |
| 2630 |
kanji,kana,other_kchar,hangul,modifier: begin |
| 2631 |
@z |
| 2632 |
|
| 2633 |
@x |
| 2634 |
kanji,kana,other_kchar: cur_l:=qi(get_jfm_pos(KANJI(cur_chr),main_f)); |
| 2635 |
letter,other_char: begin ins_kp:=true; cur_l:=qi(0); end; |
| 2636 |
char_given: begin |
| 2637 |
if is_char_ascii(cur_chr) then |
| 2638 |
begin ins_kp:=true; cur_l:=qi(0); |
| 2639 |
end |
| 2640 |
else cur_l:=qi(get_jfm_pos(KANJI(cur_chr),main_f)); |
| 2641 |
end; |
| 2642 |
char_num: begin scan_char_num; cur_chr:=cur_val; |
| 2643 |
if is_char_ascii(cur_chr) then |
| 2644 |
begin ins_kp:=true; cur_l:=qi(0); |
| 2645 |
end |
| 2646 |
else cur_l:=qi(get_jfm_pos(KANJI(cur_chr),main_f)); |
| 2647 |
end; |
| 2648 |
@y |
| 2649 |
kanji,kana,other_kchar,hangul,modifier: cur_l:=qi(get_jfm_pos(KANJI(cur_chr),main_f)); |
| 2650 |
letter,other_char: begin ins_kp:=true; cur_l:=qi(0); end; |
| 2651 |
char_given: begin |
| 2652 |
if check_echar_range(cur_chr) then |
| 2653 |
begin ins_kp:=true; cur_l:=qi(0); |
| 2654 |
end |
| 2655 |
else cur_l:=qi(get_jfm_pos(KANJI(cur_chr),main_f)); |
| 2656 |
cur_cmd:=kcat_code(kcatcodekey(cur_chr)); |
| 2657 |
end; |
| 2658 |
char_num: begin scan_char_num; cur_chr:=cur_val; |
| 2659 |
if check_echar_range(cur_chr) then |
| 2660 |
begin ins_kp:=true; cur_l:=qi(0); |
| 2661 |
end |
| 2662 |
else cur_l:=qi(get_jfm_pos(KANJI(cur_chr),main_f)); |
| 2663 |
cur_cmd:=kcat_code(kcatcodekey(cur_chr)); |
| 2664 |
end; |
| 2665 |
kchar_given: begin |
| 2666 |
cur_l:=qi(get_jfm_pos(KANJI(cur_chr),main_f)); |
| 2667 |
cur_cmd:=kcat_code(kcatcodekey(cur_chr)); |
| 2668 |
end; |
| 2669 |
kchar_num: begin scan_char_num; cur_chr:=cur_val; |
| 2670 |
cur_l:=qi(get_jfm_pos(KANJI(cur_chr),main_f)); |
| 2671 |
cur_cmd:=kcat_code(kcatcodekey(cur_chr)); |
| 2672 |
end; |
| 2673 |
@z |
| 2674 |
|
| 2675 |
@x |
| 2676 |
procedure print_kanji(@!s:KANJI_code); {prints a single character} |
| 2677 |
begin |
| 2678 |
if s>@"FF then |
| 2679 |
begin print_char(@"100+Hi(s)); print_char(@"100+Lo(s)); |
| 2680 |
end else print_char(s); |
| 2681 |
@y |
| 2682 |
procedure print_kanji(@!s:KANJI_code); {prints a single character} |
| 2683 |
var @!v,@!nn,@!jj: integer; |
| 2684 |
begin |
| 2685 |
if (isinternalUPTEX) then begin |
| 2686 |
s:=ktokentochr(s); |
| 2687 |
s:=toUCS(s); |
| 2688 |
nn:=UVSgetcodepointlength(s); |
| 2689 |
jj:=1; |
| 2690 |
while jj<=nn do begin |
| 2691 |
v:=UVSgetcodepointinsequence(s,jj); |
| 2692 |
if (v>0) then begin |
| 2693 |
v:=UCStoUTF8(v); |
| 2694 |
if BYTE1(v)<>0 then print_char(@"100+BYTE1(v)); |
| 2695 |
if BYTE2(v)<>0 then print_char(@"100+BYTE2(v)); |
| 2696 |
if BYTE3(v)<>0 then print_char(@"100+BYTE3(v)); |
| 2697 |
print_char(@"100+BYTE4(v)); |
| 2698 |
end; |
| 2699 |
incr(jj); |
| 2700 |
end |
| 2701 |
end |
| 2702 |
else begin |
| 2703 |
s:=toBUFF(s mod max_cjk_val); |
| 2704 |
if BYTE1(s)<>0 then print_char(@"100+BYTE1(s)); |
| 2705 |
if BYTE2(s)<>0 then print_char(@"100+BYTE2(s)); |
| 2706 |
if BYTE3(s)<>0 then print_char(@"100+BYTE3(s)); |
| 2707 |
print_char(@"100+BYTE4(s)); |
| 2708 |
end; |
| 2709 |
end; |
| 2710 |
|
| 2711 |
function check_kcat_code(@!ct:integer;@!cx:integer):integer; |
| 2712 |
begin |
| 2713 |
if (((ct>=kanji)or((ct=latin_ucs)and(cx<max_latin_val)))and(enable_cjk_token=0))or(enable_cjk_token=2)then |
| 2714 |
check_kcat_code:=1 |
| 2715 |
else check_kcat_code:=0; |
| 2716 |
end; |
| 2717 |
|
| 2718 |
function check_echar_range(@!c:integer):integer; |
| 2719 |
begin |
| 2720 |
if (c>127)and(c<max_latin_val)and(kcat_code(kcatcodekey(c))=latin_ucs)then |
| 2721 |
check_echar_range:=1 |
| 2722 |
else if (c>=0)and(c<256)then |
| 2723 |
check_echar_range:=2 |
| 2724 |
else check_echar_range:=0; |
| 2725 |
end; |
| 2726 |
|
| 2727 |
function check_mchar_range(@!c:integer):integer; |
| 2728 |
begin |
| 2729 |
if (c>255)and(c<max_latin_val)then |
| 2730 |
check_mchar_range:=1 |
| 2731 |
else check_mchar_range:=0; |
| 2732 |
@z |