summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/eptexdir/eptex.ech
blob: 1380574c7de13cfe48bd11f4d0cedc3e1504e2ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
% eptexdir/eptex.ech: changefile used to build e-pTeX, see eptexdir/eptex-base.ch for details.
% Public domain. Originally written by Peter Breitenlohner <tex-live@tug.org>.

@x e-pTeX: logo
\def\eTeX{$\varepsilon$-\TeX}
@y
\def\eTeX{$\varepsilon$-\TeX}
\def\epTeX{$\varepsilon$-p\TeX}
@z

@x [1.2] l.200 - pTeX:
@d pTeX_version_string=='-p3.1.11' {current p\TeX\ version}
@y
@d  pTeX_version_string=='-p3.1.11-110315' {current \epTeX\ version}
@z

@x e-pTeX: banner
  {printed when p\TeX\ starts}
@y
  {printed when p\TeX\ starts}
@#
@d epTeX_version==pTeX_version_string,eTeX_version_string
@d epTeX_banner=='This is e-pTeX, Version 3.1415926',epTeX_version
@d epTeX_banner_k==epTeX_banner
  {printed when \epTeX\ starts}
@z

@x
@d max_quarterword=255 {largest allowable value in a |quarterword|}
@y
@d max_quarterword=@"FFFF {largest allowable value in a |quarterword|}
@z

@x
@d box_dir(#) == subtype(#) {direction mode of a box}
@d set_box_dir(#) == subtype(#):=set_box_dir_end
@y
@d box_dir(#) == (subtype(#)mod 8) {direction mode of a box}
@d set_box_dir(#) == subtype(#):=(subtype(#)div 8)*8+set_box_dir_end 
@z

@x [26.424] l.8510 - e-pTeX: last node
@d find_effective_tail==find_effective_tail_pTeX
@y
@d find_effective_tail_epTeX(#)== {Ignore final |disp_node| and\slash or \.{\\endM} node}
find_effective_tail_pTeX(#);
if (type(tx)=math_node)and(subtype(tx)=end_M_code) then
  begin r:=head;
  repeat q:=r; r:=link(q); until link(r)=tx;
  if is_char_node(r) then #;
  if (type(r)=disp_node) then
    if is_char_node(q)or(q=head) then #
    else tx:=q
  else tx:=r;
  end
@#
@d find_effective_tail==find_effective_tail_epTeX
@z

@x [26.424] l.8517 - e-pTeX: node types
    if (tail=head)or(mode=0) then cur_val:=-1;
@y
    if (tail=head)or(mode=0)or@|
       ((tail=link(head))and not is_char_node(tail)and(type(tail)=disp_node))
      then cur_val:=-1;
@z

@x [26.424] e-pTeX: node types
      last_node_type_code: if type(tx)<=unset_node then cur_val:=type(tx)+1
        else cur_val:=unset_node+2;
@y
      last_node_type_code: if type(tx)<=unset_node then
          begin if type(tx)=dir_node then tx:=list_ptr(tx);
          cur_val:=type(tx);
          if cur_val<dir_node then cur_val:=cur_val+1
          else if cur_val>disp_node then cur_val:=cur_val-1;
          end
        else cur_val:=unset_node; {\epTeX's |unset_node| is \eTeX's |unset_node+2|}
@z

@x e-pTeX: if primitives - leave room for three e-TeX codes
@d if_tdir_code=if_case_code+1 { `\.{\\iftdir}' }
@y
@d if_tdir_code=if_case_code+4 { `\.{\\iftdir}' }
@z

@x
@d box_lrstat(#) == subtype(#) {direction mode of a box}
@d set_box_lrstat(#) ==  subtype(#):=set_box_lrstat_end
@d set_box_lrstat_end(#) == #
@y
@d box_lrstat(#) == (subtype(#)div 8) {direction mode of a box}
@d set_box_lrstat(#) == subtype(#):=(subtype(#)mod 8)+8*set_box_lrstat_end
@d set_box_lrstat_end(#) == (#)
@z

@x [47.1079] l.20920
@!r:pointer; {running behind |p|}
@!a_dir:eight_bits; {adjust direction}
@!disp,@!pdisp:scaled; {displacement}
@!fd:boolean; {a final |disp_node| pair?}
@!tx:pointer; {effective tail node}
@!m:quarterword; {the length of a replacement list}
@y
@!a_dir:eight_bits; {adjust direction}
@!d:pointer; {last |disp_node|}
@!disp,@!pdisp:scaled; {displacement}
@!pp,@!pnode:pointer;
@!f:boolean; {will |d| free?}
@!m:quarterword; {the length of a replacement list}
@z

@x [47.1080] l.20940
@d fetch_effective_tail==fetch_effective_tail_pTeX
@y
@d fetch_effective_tail_epTeX(#)==
@#
@d fetch_effective_tail==fetch_effective_tail_epTeX
@z

@x [47.1080] l.20950
else  begin if not is_char_node(tail)and(head<>tail) then
    begin find_effective_tail(goto done);
    if (type(tx)=hlist_node)or(type(tx)=vlist_node) then
      @<Remove the last box, unless it's part of a discretionary@>;
    done:end;
@y
else  begin f:=false;
  if (not is_char_node(tail))and(type(tail)=disp_node) then
    begin d:=tail; tail:=prev_node;
    end
  else d:=null;
  if (not is_char_node(tail))and(head<>tail) then
    if (type(tail)=hlist_node)or(type(tail)=vlist_node)
          or(type(tail)=dir_node) then
      @<Remove the last box, unless it's part of a discretionary@>;
  if d<>null then
    if (not is_char_node(tail))and(type(tail)=disp_node) then
      begin prev_node:=pnode; prev_disp:=pdisp;
      {|if prev_disp=disp_dimen(d) then free_node(tail,small_node_size)|}
      if prev_disp<>disp_dimen(d) then disp_dimen(tail):=disp_dimen(d);
      if f then free_node(d,small_node_size)
      else begin prev_node:=tail; tail_append(d); end;
      end
    else tail_append(d);
@z

@x [47.1081] l.20957
begin fetch_effective_tail(goto done);
cur_box:=tx; shift_amount(cur_box):=0;
if type(cur_box)=dir_node then
  begin link(list_ptr(cur_box)):=cur_box;
  cur_box:=list_ptr(cur_box);
  list_ptr(link(cur_box)):=null;
  end
else
  if box_dir(cur_box)=dir_default then set_box_dir(cur_box)(abs(direction));
end
@y
begin q:=head; pp:=null; pnode:=null; disp:=0; pdisp:=0;
repeat p:=q;
if not is_char_node(q) then
  if type(q)=disc_node then
    begin for m:=1 to replace_count(q) do p:=link(p);
    if p=tail then goto done;
    end
  else if type(q)=disp_node then
    begin pnode:=pp; pdisp:=disp; disp:=disp_dimen(q);
    end;
pp:=q; q:=link(p);
until q=tail;
cur_box:=tail; shift_amount(cur_box):=0;
tail:=p; link(p):=null;
if type(cur_box)=dir_node then
  begin link(list_ptr(cur_box)):=cur_box;
  cur_box:=list_ptr(cur_box);
  list_ptr(link(cur_box)):=null;
  end
else
  if box_dir(cur_box)=dir_default then set_box_dir(cur_box)(abs(direction));
done:end
@z

@x [47.1105] l.21246
@!r:pointer; {running behind |p|}
@!disp,@!pdisp:scaled; {displacement}
@!fd:boolean; {a final |disp_node| pair?}
@!tx:pointer; {effective tail node}
@!m:quarterword; {the length of a replacement list}
@y
@!d:pointer; {last |disp_node|}
@!disp,@!pdisp:scaled; {displacement}
@!pp,@!pnode:pointer;
@!f:integer;
  {0: not append |d|, 1: append |d| (|tail| is removed)}
  {2: |tail| is not removed }
@!m:quarterword; {the length of a replacement list}
@z

@x [47.1105] l.21250
else if not is_char_node(tail) then
  begin find_effective_tail(return);
  if type(tx)<>cur_chr then return;
  fetch_effective_tail(return);
  flush_node_list(tx);
@y
else  begin
  if (not is_char_node(tail))and(type(tail)=disp_node) then
    begin f:=2; d:=tail; tail:=prev_node; link(tail):=null;
    end
  else d:=null;
  if not is_char_node(tail) then if type(tail)=cur_chr then
    begin q:=head; pp:=null; pnode:=null; disp:=0; pdisp:=0; f:=0;
    repeat p:=q;
    if not is_char_node(q) then
      if type(q)=disc_node then
        begin for m:=1 to replace_count(q) do p:=link(p);
        if p=tail then
          begin if d<>null then tail_append(d);
          return;
          end
        else if link(p)=tail then f:=1;
        end
      else if type(q)=disp_node then
        begin pnode:=pp; pdisp:=disp; disp:=disp_dimen(q);
        end;
    pp:=q; q:=link(p);
    until q=tail;
    link(p):=null; flush_node_list(tail); tail:=p;
    end;
  if d<>null then
    if f<=1 then
      begin prev_node:=pnode; prev_disp:=pdisp;
      if (f=0)and(not is_char_node(tail))and(type(tail)=disp_node) then
        begin disp_dimen(tail):=disp_dimen(d); free_node(d,small_node_size)
        end
      else begin prev_node:=tail; prev_disp:=disp; tail_append(d);
        end;
      end
    else tail_append(d);
@z

@x e-pTeX: font_char_{wd,ht,dp,ic}_code l.27306
    begin i:=char_info(q)(qi(cur_val));
@y
    begin i:=orig_char_info(q)(qi(cur_val));
@z

@x e-pTeX: displacement value when typesetting right-to-left l.27798
@!LR_temp:pointer; {holds a temporarily removed \.{\\endM} node}
@y
@!revdisp:scaled; {temporary value of displacement}
@!LR_temp:pointer; {holds a temporarily removed \.{\\endM} node}
@z

@x e-pTeX: reverse nodes of an hlist l.28010
var l:pointer; {the new list}
@y
var l,la:pointer; {the new list}
disp,disp2: scaled; { displacement } disped: boolean;
@z
@x e-pTeX: reverse nodes of an hlist l.28010
begin g_order:=glue_order(this_box); g_sign:=glue_sign(this_box);
@y 
begin g_order:=glue_order(this_box); g_sign:=glue_sign(this_box);
disp:=revdisp; disped:=false;
@z
@x e-pTeX: reverse nodes of an hlist l.28010
done:reverse:=l;
@y
done: {if the beginning node of the new list isn't |disp_node|,
       we insert |disp_node| to fix.}
if (l<>null)and(type(l)<>disp_node) then begin
  p:=get_node(small_node_size); type(p):=disp_node;
  disp_dimen(p):=disp; link(p):=l; reverse:=p;
  end
else reverse:=l;
@z
@x e-pTeX: reverse nodes of an hlist l.28010
  q:=link(p); link(p):=l; l:=p; p:=q;
@y
  if font_dir[f]<>dir_default then begin
    q:=link(p); la:=l; l:=p; p:=link(q); link(q):=la;
    end
  else begin q:=link(p); link(p):=l; l:=p; p:=q; end;
@z
@x e-pTeX: reverse nodes of an hlist l.28010
othercases goto next_p
@y
disp_node: begin
  disp2:=disp_dimen(p); disp_dimen(p):=disp; disp:=disp2;
  { print_nl("ep TeXXeT:"); print_int(disp_dimen(p)); }
  { print(" -> "); print_int(disp); }
  { if not disped then begin disped:=true; print(" NL"); end; end; }
  if not disped then disped:=true; end;
othercases goto next_p
@z

@x e-pTeX: ifcsname l.28620
  buffer[m]:=info(p) mod @'400; incr(m); p:=link(p);
@y
  if check_kanji(info(p)) then {wchar_token}
    begin buffer[m]:=Hi(info(p)); incr(m);
    end;
  buffer[m]:=Lo(info(p)); incr(m); p:=link(p);
@z

@x e-pTeX: if_font_char_code l.28633
    b:=char_exists(char_info(n)(qi(cur_val)))
@y
    b:=char_exists(orig_char_info(n)(qi(cur_val)))
@z

@x
procedure print_direction(@!d:integer); {print the direction represented by d}
@y
procedure print_direction_alt(@!d:integer);
var x: boolean;
begin x:=false;
case abs(d) of
dir_yoko: begin print(", yoko"); x:=true; end;
dir_tate: begin print(", tate"); x:=true; end;
dir_dtou: begin print(", dtou"); x:=true; end;
end;
if x then begin if d<0 then print("(math)");
print(" direction"); end;
end;
@#
procedure print_direction(@!d:integer); {print the direction represented by d}
@z