Debian Codegraph @

texk/web2c/alephdir/omstr.ch

raw
1 % omstr.ch: String manipulation
2 %
3 % This file is part of the Omega project, which
4 % is based on the web2c distribution of TeX.
5 %
6 % Copyright (c) 1994--2000 John Plaice and Yannis Haralambous
7 %
8 % This library is free software; you can redistribute it and/or
9 % modify it under the terms of the GNU Library General Public
10 % License as published by the Free Software Foundation; either
11 % version 2 of the License, or (at your option) any later version.
12 %
13 % This library is distributed in the hope that it will be useful,
14 % but WITHOUT ANY WARRANTY; without even the implied warranty of
15 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 % Library General Public License for more details.
17 %
18 % You should have received a copy of the GNU Library General Public
19 % License along with this library; if not, write to the Free Software
20 % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 %
22 %---------------------------------------
23 @x [2] m.17 l.510 - Omega
24 In order to make \TeX\ readily portable to a wide variety of
25 computers, all of its input text is converted to an internal eight-bit
26 @y
27 In order to make $\Omega$ readily portable to a wide variety of
28 computers, all of its input text is converted to an internal 31-bit
29 @z
30 %---------------------------------------
31 @x [2] m.18 l.537 - Omega
32 @!ASCII_code=0..255; {eight-bit numbers}
33 @y
34 @!ASCII_code=0..biggest_char;
35 @z
36 %---------------------------------------
37 @x [2] m.19 l.567 - Omega
38 @d last_text_char=255 {ordinal number of the largest element of |text_char|}
39 @y
40 @d last_text_char=biggest_char
41 {ordinal number of the largest element of |text_char|}
42 @z
43 %---------------------------------------
44 @x [2] m.20 l.577 - Omega
45 @!xord: array [text_char] of ASCII_code;
46 {specifies conversion of input characters}
47 @!xchr: array [ASCII_code] of text_char;
48 {specifies conversion of output characters}
49 @y
50 @!xchr: array [0..255] of text_char;
51 {specifies conversion of output characters}
52 @z
53 %---------------------------------------
54 @x [2] m.23 l.724 - Omega
55 for i:=0 to @'37 do xchr[i]:=' ';
56 for i:=@'177 to @'377 do xchr[i]:=' ';
57 @y
58 for i:=0 to @'37 do xchr[i]:=chr(i);
59 for i:=@'177 to @'377 do xchr[i]:=chr(i);
60 init_eqtb_table;
61 @z
62 %---------------------------------------
63 @x [2] m.24 l.734 - Omega
64 for i:=first_text_char to last_text_char do xord[chr(i)]:=invalid_code;
65 for i:=@'200 to @'377 do xord[xchr[i]]:=i;
66 for i:=0 to @'176 do xord[xchr[i]]:=i;
67 @y
68 @z
69 %---------------------------------------
70 @x [3] m.25 l.772 - Omega
71 @!eight_bits=0..255; {unsigned one-byte quantity}
72 @!alpha_file=packed file of text_char; {files that contain textual data}
73 @!byte_file=packed file of eight_bits; {files that contain binary data}
74 @y
75 @!eight_bits=0..biggest_char; {unsigned two-byte quantity}
76 @!real_eight_bits=0..255; {dvi output uses exactly 8 bits}
77 @!alpha_file=packed file of text_char; {files that contain textual data}
78 @!byte_file=packed file of real_eight_bits; {files that contain binary data}
79 @z
80 %---------------------------------------
81 @x [3] m.31 l.947 - Omega
82 buffer[last]:=xord[f^]; get(f); incr(last);
83 @y
84 buffer[last]:=f^; get(f); incr(last);
85 @z
86 %---------------------------------------
87 @x [4] m.38 l.1099 - Omega
88 String numbers 0 to 255 are reserved for strings that correspond to single
89 ASCII characters. This is in accordance with the conventions of \.{WEB},
90 @y
91 String numbers 0 to |biggest_char| are reserved for strings that correspond to
92 single ASCII characters. This is in accordance with the conventions of \.{WEB},
93 @z
94 %---------------------------------------
95 @x [4] m.38 l.1109 - Omega
96 ASCII character, so the first 256 strings are used to specify exactly what
97 should be printed for each of the 256 possibilities.
98 @y
99 ASCII character, so the first |biggest_char+1| strings are used to specify
100 exactly what should be printed for each of the |biggest_char+1| possibilities.
101 @z
102 %---------------------------------------
103 @x [4] m.38-9 l.1122 - Omega
104 @d si(#) == # {convert from |ASCII_code| to |packed_ASCII_code|}
105 @d so(#) == # {convert from |packed_ASCII_code| to |ASCII_code|}
106
107 @<Types...@>=
108 @!pool_pointer = 0..pool_size; {for variables that point into |str_pool|}
109 @!str_number = 0..max_strings; {for variables that point into |str_start|}
110 @!packed_ASCII_code = 0..255; {elements of |str_pool| array}
111
112 @ @<Glob...@>=
113 @!str_pool:packed array[pool_pointer] of packed_ASCII_code; {the characters}
114 @!str_start : array[str_number] of pool_pointer; {the starting pointers}
115 @y
116 @d si(#) == # {convert from |ASCII_code| to |packed_ASCII_code|}
117 @d so(#) == # {convert from |packed_ASCII_code| to |ASCII_code|}
118 @d str_start(#) == str_start_ar[#-too_big_char]
119
120 @<Types...@>=
121 @!pool_pointer = 0..pool_size; {for variables that point into |str_pool|}
122 @!str_number = 0..max_strings; {for variables that point into |str_start|}
123 @!packed_ASCII_code = 0..65535; {elements of |str_pool| array}
124
125 @ @<Glob...@>=
126 @!str_pool:packed array[pool_pointer] of packed_ASCII_code; {the characters}
127 @!str_start_ar : array[str_number] of pool_pointer; {the starting pointers}
128 @z
129 %---------------------------------------
130 @x [4] m.40 l.1145 - Omega
131 @d length(#)==(str_start[#+1]-str_start[#]) {the number of characters
132 in string number \#}
133 @y
134 @p function length(s:str_number):integer;
135 {the number of characters in string number |s|}
136 begin if (s>=@"10000) then length:=str_start(s+1)-str_start(s)
137 else if (s>=@"20) and (s<@"7F) then length:=1
138 else if (s<=@"7F) then length:=3
139 else if (s<@"100) then length:=4
140 else length:=8
141 end;
142 @z
143 %---------------------------------------
144 @x [4] m.41 l.1150 - Omega
145 @d cur_length == (pool_ptr - str_start[str_ptr])
146 @y
147 @d cur_length == (pool_ptr - str_start(str_ptr))
148 @z
149 %---------------------------------------
150 @x [4] m.43 l.1181 - Omega
151 incr(str_ptr); str_start[str_ptr]:=pool_ptr;
152 @y
153 incr(str_ptr); str_start(str_ptr):=pool_ptr;
154 @z
155 %---------------------------------------
156 @x [4] m.44 l.1187 - Omega
157 @d flush_string==begin decr(str_ptr); pool_ptr:=str_start[str_ptr];
158 @y
159 @d flush_string==begin decr(str_ptr); pool_ptr:=str_start(str_ptr);
160 @z
161 %---------------------------------------
162 @x [4] m.45 l.1201 - Omega
163 begin j:=str_start[s];
164 while j<str_start[s+1] do
165 @y
166 begin j:=str_start(s);
167 while j<str_start(s+1) do
168 @z
169 %---------------------------------------
170 @x [4] m.46 l.1222 - Omega
171 @p function str_eq_str(@!s,@!t:str_number):boolean;
172 {test equality of strings}
173 label not_found; {loop exit}
174 var j,@!k: pool_pointer; {running indices}
175 @!result: boolean; {result of comparison}
176 begin result:=false;
177 if length(s)<>length(t) then goto not_found;
178 j:=str_start[s]; k:=str_start[t];
179 while j<str_start[s+1] do
180 begin if str_pool[j]<>str_pool[k] then goto not_found;
181 incr(j); incr(k);
182 end;
183 result:=true;
184 not_found: str_eq_str:=result;
185 end;
186 @y
187 @p function str_eq_str(@!s,@!t:str_number):boolean;
188 {test equality of strings}
189 label not_found; {loop exit}
190 var j,@!k: pool_pointer; {running indices}
191 @!result: boolean; {result of comparison}
192 begin result:=false;
193 if length(s)<>length(t) then goto not_found;
194 if (length(s)=1) then begin
195 if s<65536 then begin
196 if t<65536 then begin
197 if s<>t then goto not_found;
198 end
199 else begin
200 if s<>str_pool[str_start(t)] then goto not_found;
201 end;
202 end
203 else begin
204 if t<65536 then begin
205 if str_pool[str_start(s)]<>t then goto not_found;
206 end
207 else begin
208 if str_pool[str_start(s)]<>str_pool[str_start(t)] then
209 goto not_found;
210 end;
211 end;
212 end
213 else begin
214 j:=str_start(s); k:=str_start(t);
215 while j<str_start(s+1) do
216 begin if str_pool[j]<>str_pool[k] then goto not_found;
217 incr(j); incr(k);
218 end;
219 end;
220 result:=true;
221 not_found: str_eq_str:=result;
222 end;
223 @z
224 %---------------------------------------
225 @x [4] m.47 l.1240 - Omega
226 var k,@!l:0..255; {small indices or counters}
227 @y
228 var k,@!l:0..biggest_char; {small indices or counters}
229 @z
230 %---------------------------------------
231 @x [4] m.47 l.1245 - Omega
232 begin pool_ptr:=0; str_ptr:=0; str_start[0]:=0;
233 @<Make the first 256 strings@>;
234 @<Read the other strings from the \.{TEX.POOL} file and return |true|,
235 @y
236 begin pool_ptr:=0; str_ptr:=0; str_start_ar[0]:=0; str_start_ar[1]:=0;
237 @<Make the first strings@>;
238 @<Read the other strings from the \.{OMEGA.POOL} file and return |true|,
239 @z
240 %---------------------------------------
241 % A hack is made for strings 256 through to 65535.
242 % String 256 becomes "^^^^????". All the strings
243 % from 256 to 65535 are made to point at this string,
244 % which will never be printed: it's just a placeholder.
245
246 @x [4] m.48 l.1255 - Omega
247 @<Make the first 256...@>=
248 for k:=0 to 255 do
249 begin if (@<Character |k| cannot be printed@>) then
250 begin append_char("^"); append_char("^");
251 if k<@'100 then append_char(k+@'100)
252 else if k<@'200 then append_char(k-@'100)
253 else begin app_lc_hex(k div 16); app_lc_hex(k mod 16);
254 end;
255 end
256 else append_char(k);
257 g:=make_string;
258 end
259 @y
260 @<Make the first ...@>=
261 begin
262 str_ptr:=too_big_char;
263 end
264 @z
265 %---------------------------------------
266 @x [4] m.49 l.1279 - Omega
267 Unprintable characters of codes 128--255 are, similarly, rendered
268 \.{\^\^80}--\.{\^\^ff}.
269 @y
270 Unprintable characters of codes 128--255 are, similarly, rendered
271 \.{\^\^80}--\.{\^\^ff}.
272
273 Unprintable characters of codes 256--|biggest_char| are, similarly, rendered
274 \.{\^\^\^\^0100}--\.{\^\^\^\^ffff}.
275
276 @z
277 %---------------------------------------
278 @x [4] m.49 l.1295 - Omega
279 @<Character |k| cannot be printed@>=
280 (k<" ")or(k>"~")
281 @y
282 @z
283 %---------------------------------------
284 @x [4] m.50 l.1298 - Omega
285 @ When the \.{WEB} system program called \.{TANGLE} processes the \.{TEX.WEB}
286 description that you are now reading, it outputs the \PASCAL\ program
287 \.{TEX.PAS} and also a string pool file called \.{TEX.POOL}. The \.{INITEX}
288 @y
289 @ When the \.{WEB} system program called \.{OTANGLE} processes the \.{OMEGA.WEB}
290 description that you are now reading, it outputs the \PASCAL\ program
291 \.{OMEGA.PAS} and also a string pool file called \.{OMEGA.POOL}. The \.{INITEX}
292 @z
293 %---------------------------------------
294 @x [4] m.51 l.1322 - Omega
295 else bad_pool('! I can''t read TEX.POOL.')
296 @.I can't read TEX.POOL@>
297 @y
298 else bad_pool('! I can''t read OMEGA.POOL.')
299 @.I can't read OMEGA.POOL@>
300 @z
301 %---------------------------------------
302 @x [4] m.52 l.1326 - Omega
303 begin if eof(pool_file) then bad_pool('! TEX.POOL has no check sum.');
304 @.TEX.POOL has no check sum@>
305 @y
306 begin if eof(pool_file) then bad_pool('! OMEGA.POOL has no check sum.');
307 @.OMEGA.POOL has no check sum@>
308 @z
309 %---------------------------------------
310 @x [4] m.52 l.1332 - Omega
311 else begin if (xord[m]<"0")or(xord[m]>"9")or@|
312 (xord[n]<"0")or(xord[n]>"9") then
313 bad_pool('! TEX.POOL line doesn''t begin with two digits.');
314 @.TEX.POOL line doesn't...@>
315 l:=xord[m]*10+xord[n]-"0"*11; {compute the length}
316 if pool_ptr+l+string_vacancies>pool_size then
317 bad_pool('! You have to increase POOLSIZE.');
318 @.You have to increase POOLSIZE@>
319 for k:=1 to l do
320 begin if eoln(pool_file) then m:=' '@+else read(pool_file,m);
321 append_char(xord[m]);
322 @y
323 else begin if (m<"0")or(m>"9")or@|
324 (n<"0")or(n>"9") then
325 bad_pool('! OMEGA.POOL line doesn''t begin with two digits.');
326 @.OMEGA.POOL line doesn't...@>
327 l:=m*10+n-"0"*11; {compute the length}
328 if pool_ptr+l+string_vacancies>pool_size then
329 bad_pool('! You have to increase POOLSIZE.');
330 @.You have to increase POOLSIZE@>
331 for k:=1 to l do
332 begin if eoln(pool_file) then m:=' '@+else read(pool_file,m);
333 append_char(m);
334 @z
335 %---------------------------------------
336 @x [4] m.53 l.1347 - Omega
337 end of this \.{TEX.POOL} file; any other value means that the wrong pool
338 @y
339 end of this \.{OMEGA.POOL} file; any other value means that the wrong pool
340 @z
341 %---------------------------------------
342 @x [4] m.53 l.1354 - Omega
343 loop@+ begin if (xord[n]<"0")or(xord[n]>"9") then
344 bad_pool('! TEX.POOL check sum doesn''t have nine digits.');
345 @.TEX.POOL check sum...@>
346 a:=10*a+xord[n]-"0";
347 @y
348 loop@+ begin if (n<"0")or(n>"9") then
349 bad_pool('! OMEGA.POOL check sum doesn''t have nine digits.');
350 @.OMEGA.POOL check sum...@>
351 a:=10*a+n-"0";
352 @z
353 %---------------------------------------
354 @x [4] m.53 l.1360 - Omega
355 done: if a<>@$ then bad_pool('! TEX.POOL doesn''t match; TANGLE me again.');
356 @.TEX.POOL doesn't match@>
357 @y
358 done: if a<>@$ then bad_pool('! OMEGA.POOL doesn''t match; OTANGLE me again.');
359 @.OMEGA.POOL doesn't match@>
360 @z
361 %---------------------------------------
362 % When we print a string, we must make sure we do the appropriate
363 % thing for strings 256 through to 65535. We must generate the
364 % strings on the fly.
365
366 @x [5] m.59 l.1496 - Omega
367 @ An entire string is output by calling |print|. Note that if we are outputting
368 the single standard ASCII character \.c, we could call |print("c")|, since
369 |"c"=99| is the number of a single-character string, as explained above. But
370 |print_char("c")| is quicker, so \TeX\ goes directly to the |print_char|
371 routine when it knows that this is safe. (The present implementation
372 assumes that it is always safe to print a visible ASCII character.)
373 @^system dependencies@>
374
375 @<Basic print...@>=
376 procedure print(@!s:integer); {prints string |s|}
377 label exit;
378 var j:pool_pointer; {current character code position}
379 @!nl:integer; {new-line character to restore}
380 begin if s>=str_ptr then s:="???" {this can't happen}
381 @.???@>
382 else if s<256 then
383 if s<0 then s:="???" {can't happen}
384 else begin if selector>pseudo then
385 begin print_char(s); return; {internal strings are not expanded}
386 end;
387 if (@<Character |s| is the current new-line character@>) then
388 if selector<pseudo then
389 begin print_ln; return;
390 end;
391 nl:=new_line_char; new_line_char:=-1;
392 {temporarily disable new-line character}
393 j:=str_start[s];
394 while j<str_start[s+1] do
395 begin print_char(so(str_pool[j])); incr(j);
396 end;
397 new_line_char:=nl; return;
398 end;
399 j:=str_start[s];
400 while j<str_start[s+1] do
401 @y
402 @ An entire string is output by calling |print|. Note that if we are outputting
403 the single standard ASCII character \.c, we could call |print("c")|, since
404 |"c"=99| is the number of a single-character string, as explained above. But
405 |print_char("c")| is quicker, so \TeX\ goes directly to the |print_char|
406 routine when it knows that this is safe. (The present implementation
407 assumes that it is always safe to print a visible ASCII character.)
408 @^system dependencies@>
409
410 @d print_lc_hex(#)==l:=#;
411 if l<10 then print_char(l+"0") else print_char(l-10+"a");
412
413 @<Basic print...@>=
414 procedure print(@!s:integer); {prints string |s|}
415 label exit;
416 var j:pool_pointer; {current character code position}
417 @!nl:integer; {new-line character to restore}
418 @!l:integer; {for printing 16-bit characters}
419 begin if s>=str_ptr then s:="???" {this can't happen}
420 @.???@>
421 else if s<biggest_char then
422 if s<0 then s:="???" {can't happen}
423 else begin if selector>pseudo then
424 begin print_char(s); return; {internal strings are not expanded}
425 end;
426 if (@<Character |s| is the current new-line character@>) then
427 if selector<pseudo then
428 begin print_ln; return;
429 end;
430 nl:=new_line_char;
431 @<Set newline character to -1@>;
432 if s<@"20 then begin
433 print_char(@"5E); print_char(@"5E); print_char(s+@'100);
434 end
435 else if s<@"7F then
436 print_char(s)
437 else if s=@"7F then begin
438 print_char(@"5E); print_char(@"5E); print_char(s-@'100);
439 end
440 else if s<@"100 then begin
441 print_char(@"5E); print_char(@"5E);
442 print_lc_hex((s mod @"100) div @"10); print_lc_hex(s mod @"10);
443 end
444 else begin {Here is where we generate the strings on the fly.}
445 print_char(@"5E); print_char(@"5E);
446 print_char(@"5E); print_char(@"5E);
447 print_lc_hex(s div @"1000); print_lc_hex((s mod @"1000) div @"100);
448 print_lc_hex((s mod @"100) div @"10); print_lc_hex(s mod @"10);
449 end;
450 @<Set newline character to nl@>;
451 return;
452 end;
453 j:=str_start(s);
454 while j<str_start(s+1) do
455 @z
456 %---------------------------------------
457 @x [5] m.60 l.1539 - Omega
458 procedure slow_print(@!s:integer); {prints string |s|}
459 var j:pool_pointer; {current character code position}
460 begin if (s>=str_ptr) or (s<256) then print(s)
461 else begin j:=str_start[s];
462 while j<str_start[s+1] do
463 @y
464 procedure slow_print(@!s:integer); {prints string |s|}
465 var j:pool_pointer; {current character code position}
466 begin if (s>=str_ptr) or (s<=biggest_char) then print(s)
467 else begin j:=str_start(s);
468 while j<str_start(s+1) do
469 @z
470 %---------------------------------------
471 @x [5] m.61 l.1556 - Omega
472 wterm(banner);
473 if format_ident=0 then wterm_ln(' (no format preloaded)')
474 else begin slow_print(format_ident); print_ln;
475 end;
476 update_terminal;
477 @y
478 wterm(banner);
479 if format_ident=0 then wterm_ln(' (no format preloaded)')
480 else begin slow_print(format_ident); print_ln;
481 end;
482 wterm_ln('Copyright (c) 1994--2000 John Plaice and Yannis Haralambous');
483 update_terminal;
484 @z
485 %---------------------------------------
486 @x [5] m.63 l.1576 - Omega
487 procedure print_esc(@!s:str_number); {prints escape character, then |s|}
488 var c:integer; {the escape character code}
489 begin @<Set variable |c| to the current escape character@>;
490 if c>=0 then if c<256 then print(c);
491 @y
492 procedure print_esc(@!s:str_number); {prints escape character, then |s|}
493 var c:integer; {the escape character code}
494 begin @<Set variable |c| to the current escape character@>;
495 if c>=0 then if c<=biggest_char then print(c);
496 @z
497 %---------------------------------------
498 @x [5] m.69 l.1654 - Omega
499 @p procedure print_roman_int(@!n:integer);
500 label exit;
501 var j,@!k: pool_pointer; {mysterious indices into |str_pool|}
502 @!u,@!v: nonnegative_integer; {mysterious numbers}
503 begin j:=str_start["m2d5c2l5x2v5i"]; v:=1000;
504 @y
505 @p procedure print_roman_int(@!n:integer);
506 label exit;
507 var j,@!k: pool_pointer; {mysterious indices into |str_pool|}
508 @!u,@!v: nonnegative_integer; {mysterious numbers}
509 begin j:=str_start("m2d5c2l5x2v5i"); v:=1000;
510 @z
511 %---------------------------------------
512 @x [5] m.70 l.1674 - Omega
513 @p procedure print_current_string; {prints a yet-unmade string}
514 var j:pool_pointer; {points to current character code}
515 begin j:=str_start[str_ptr];
516 @y
517 @p procedure print_current_string; {prints a yet-unmade string}
518 var j:pool_pointer; {points to current character code}
519 begin j:=str_start(str_ptr);
520 @z
521 %---------------------------------------
522 @x [6] m.94 l.2052 - Omega
523 print_err("TeX capacity exceeded, sorry [");
524 @y
525 print_err("Omega capacity exceeded, sorry [");
526 @z
527 %---------------------------------------
528 @x [18] m.260 l.5532 - Omega
529 while pool_ptr>str_start[str_ptr] do
530 @y
531 while pool_ptr>str_start(str_ptr) do
532 @z
533 %---------------------------------------
534 @x [18] m.264 l.5610 - Omega
535 else begin k:=str_start[s]; l:=str_start[s+1]-k;
536 @y
537 else begin k:=str_start(s); l:=str_start(s+1)-k;
538 @z
539 %---------------------------------------
540 @x [24] m.341 l.7219 - Omega
541 @!c,@!cc:ASCII_code; {constituents of a possible expanded code}
542 @!d:2..3; {number of excess characters in an expanded code}
543 @y
544 @!c,@!cc,@!ccc,@!cccc:ASCII_code; {constituents of a possible expanded code}
545 @!d:2..7; {number of excess characters in an expanded code}
546 @z
547 %---------------------------------------
548 @x [24] m.352 l.7349 - Omega
549 else cur_chr:=16*cur_chr+cc-"a"+10
550 @y
551 else cur_chr:=16*cur_chr+cc-"a"+10
552 @d long_hex_to_cur_chr==
553 if c<="9" then cur_chr:=c-"0" @+else cur_chr:=c-"a"+10;
554 if cc<="9" then cur_chr:=16*cur_chr+cc-"0"
555 else cur_chr:=16*cur_chr+cc-"a"+10;
556 if ccc<="9" then cur_chr:=16*cur_chr+ccc-"0"
557 else cur_chr:=16*cur_chr+ccc-"a"+10;
558 if cccc<="9" then cur_chr:=16*cur_chr+cccc-"0"
559 else cur_chr:=16*cur_chr+cccc-"a"+10
560
561 @z
562 %---------------------------------------
563 @x [24] m.352 l.7353 - Omega
564 begin c:=buffer[loc+1]; @+if c<@'200 then {yes we have an expanded char}
565 @y
566 begin if (cur_chr=buffer[loc+1]) and (cur_chr=buffer[loc+2]) and
567 ((loc+6)<=limit) then
568 begin c:=buffer[loc+3]; cc:=buffer[loc+4];
569 ccc:=buffer[loc+5]; cccc:=buffer[loc+6];
570 if is_hex(c) and is_hex(cc) and is_hex(ccc) and is_hex(cccc) then
571 begin loc:=loc+7; long_hex_to_cur_chr; goto reswitch;
572 end;
573 end;
574 c:=buffer[loc+1]; @+if c<@'200 then {yes we have an expanded char}
575 @z
576 %---------------------------------------
577 @x [24] m.355 l.7416 - Omega
578 begin if buffer[k]=cur_chr then @+if cat=sup_mark then @+if k<limit then
579 begin c:=buffer[k+1]; @+if c<@'200 then {yes, one is indeed present}
580 begin d:=2;
581 if is_hex(c) then @+if k+2<=limit then
582 begin cc:=buffer[k+2]; @+if is_hex(cc) then incr(d);
583 end;
584 if d>2 then
585 begin hex_to_cur_chr; buffer[k-1]:=cur_chr;
586 end
587 else if c<@'100 then buffer[k-1]:=c+@'100
588 else buffer[k-1]:=c-@'100;
589 limit:=limit-d; first:=first-d;
590 while k<=limit do
591 begin buffer[k]:=buffer[k+d]; incr(k);
592 end;
593 goto start_cs;
594 end;
595 end;
596 end
597
598 @y
599 begin if buffer[k]=cur_chr then @+if cat=sup_mark then @+if k<limit then
600 begin if (cur_chr=buffer[k+1]) and (cur_chr=buffer[k+2]) and
601 ((k+6)<=limit) then
602 begin c:=buffer[k+3]; cc:=buffer[k+4];
603 ccc:=buffer[k+5]; cccc:=buffer[k+6];
604 if is_hex(c) and is_hex(cc) and is_hex(ccc) and is_hex(cccc) then
605 begin d:=7; long_hex_to_cur_chr; buffer[k-1]:=cur_chr;
606 while k<=limit do
607 begin buffer[k]:=buffer[k+d]; incr(k);
608 end;
609 goto start_cs;
610 end
611 end
612 else begin
613 c:=buffer[k+1]; @+if c<@'200 then {yes, one is indeed present}
614 begin
615 d:=2;
616 if is_hex(c) then @+if k+2<=limit then
617 begin cc:=buffer[k+2]; @+if is_hex(cc) then incr(d);
618 end;
619 if d>2 then
620 begin hex_to_cur_chr; buffer[k-1]:=cur_chr;
621 end
622 else if c<@'100 then buffer[k-1]:=c+@'100
623 else buffer[k-1]:=c-@'100;
624 limit:=limit-d; first:=first-d;
625 while k<=limit do
626 begin buffer[k]:=buffer[k+d]; incr(k);
627 end;
628 goto start_cs;
629 end
630 end
631 end
632 end
633 @z
634 %---------------------------------------
635 @x [26] m.407 l.8216 - Omega
636 begin p:=backup_head; link(p):=null; k:=str_start[s];
637 while k<str_start[s+1] do
638 begin get_x_token; {recursion is possible here}
639 @^recursion@>
640 if (cur_cs=0)and@|
641 ((cur_chr=so(str_pool[k]))or(cur_chr=so(str_pool[k])-"a"+"A")) then
642 begin store_new_token(cur_tok); incr(k);
643 end
644 else if (cur_cmd<>spacer)or(p<>backup_head) then
645 begin back_input;
646 if p<>backup_head then back_list(link(backup_head));
647 scan_keyword:=false; return;
648 end;
649 end;
650 @y
651 begin p:=backup_head; link(p):=null;
652 if s<too_big_char then begin
653 while true do
654 begin get_x_token; {recursion is possible here}
655 @^recursion@>
656 if (cur_cs=0)and@|
657 ((cur_chr=s)or(cur_chr=s-"a"+"A")) then
658 begin store_new_token(cur_tok);
659 flush_list(link(backup_head)); scan_keyword:=true; return;
660 end
661 else if (cur_cmd<>spacer)or(p<>backup_head) then
662 begin back_input;
663 if p<>backup_head then back_list(link(backup_head));
664 scan_keyword:=false; return;
665 end;
666 end;
667 end;
668 k:=str_start(s);
669 while k<str_start(s+1) do
670 begin get_x_token; {recursion is possible here}
671 @^recursion@>
672 if (cur_cs=0)and@|
673 ((cur_chr=so(str_pool[k]))or(cur_chr=so(str_pool[k])-"a"+"A")) then
674 begin store_new_token(cur_tok); incr(k);
675 end
676 else if (cur_cmd<>spacer)or(p<>backup_head) then
677 begin back_input;
678 if p<>backup_head then back_list(link(backup_head));
679 scan_keyword:=false; return;
680 end;
681 end;
682 @z
683 %---------------------------------------
684 @x [29] m.517 l.10005 - Omega
685 @p procedure end_name;
686 begin if str_ptr+3>max_strings then
687 overflow("number of strings",max_strings-init_str_ptr);
688 @:TeX capacity exceeded number of strings}{\quad number of strings@>
689 if area_delimiter=0 then cur_area:=""
690 else begin cur_area:=str_ptr;
691 str_start[str_ptr+1]:=str_start[str_ptr]+area_delimiter; incr(str_ptr);
692 end;
693 if ext_delimiter=0 then
694 begin cur_ext:=""; cur_name:=make_string;
695 end
696 else begin cur_name:=str_ptr;
697 str_start[str_ptr+1]:=str_start[str_ptr]+ext_delimiter-area_delimiter-1;
698 @y
699 @p procedure end_name;
700 begin if str_ptr+3>max_strings then
701 overflow("number of strings",max_strings-init_str_ptr);
702 @:TeX capacity exceeded number of strings}{\quad number of strings@>
703 if area_delimiter=0 then cur_area:=""
704 else begin cur_area:=str_ptr;
705 str_start(str_ptr+1):=str_start(str_ptr)+area_delimiter; incr(str_ptr);
706 end;
707 if ext_delimiter=0 then
708 begin cur_ext:=""; cur_name:=make_string;
709 end
710 else begin cur_name:=str_ptr;
711 str_start(str_ptr+1):=str_start(str_ptr)+ext_delimiter-area_delimiter-1;
712 @z
713 %---------------------------------------
714 @x [29] m.519 l.10039 - Omega
715 if k<=file_name_size then name_of_file[k]:=xchr[c];
716 end
717
718 @p procedure pack_file_name(@!n,@!a,@!e:str_number);
719 var k:integer; {number of positions filled in |name_of_file|}
720 @!c: ASCII_code; {character being packed}
721 @!j:pool_pointer; {index into |str_pool|}
722 begin k:=0;
723 for j:=str_start[a] to str_start[a+1]-1 do append_to_name(so(str_pool[j]));
724 for j:=str_start[n] to str_start[n+1]-1 do append_to_name(so(str_pool[j]));
725 for j:=str_start[e] to str_start[e+1]-1 do append_to_name(so(str_pool[j]));
726 @y
727 if k<=file_name_size then name_of_file[k]:=xchr[c];
728 end
729
730 @p procedure pack_file_name(@!n,@!a,@!e:str_number);
731 var k:integer; {number of positions filled in |name_of_file|}
732 @!c: ASCII_code; {character being packed}
733 @!j:pool_pointer; {index into |str_pool|}
734 begin k:=0;
735 for j:=str_start(a) to str_start(a+1)-1 do append_to_name(so(str_pool[j]));
736 for j:=str_start(n) to str_start(n+1)-1 do append_to_name(so(str_pool[j]));
737 for j:=str_start(e) to str_start(e+1)-1 do append_to_name(so(str_pool[j]));
738 @z
739 %---------------------------------------
740 @x [29] m.523 l.10095 - Omega
741 for j:=1 to n do append_to_name(xord[TEX_format_default[j]]);
742 for j:=a to b do append_to_name(buffer[j]);
743 for j:=format_default_length-format_ext_length+1 to format_default_length do
744 append_to_name(xord[TEX_format_default[j]]);
745 @y
746 for j:=1 to n do append_to_name(TEX_format_default[j]);
747 for j:=a to b do append_to_name(buffer[j]);
748 for j:=format_default_length-format_ext_length+1 to format_default_length do
749 append_to_name(TEX_format_default[j]);
750 @z
751 %---------------------------------------
752 @x [29] m.524 l.10155 - Omega
753 else begin for k:=1 to name_length do append_char(xord[name_of_file[k]]);
754 @y
755 else begin for k:=1 to name_length do append_char(name_of_file[k]);
756 @z
757 %---------------------------------------
758 @x [29] m.536 l.10324 - Omega
759 begin wlog(banner);
760 slow_print(format_ident); print(" ");
761 print_int(sys_day); print_char(" ");
762 months:='JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC';
763 for k:=3*sys_month-2 to 3*sys_month do wlog(months[k]);
764 print_char(" "); print_int(sys_year); print_char(" ");
765 print_two(sys_time div 60); print_char(":"); print_two(sys_time mod 60);
766 end
767 @y
768 begin wlog(banner);
769 slow_print(format_ident); print_nl("");
770 print_int(day); print_char(" ");
771 months:='JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC';
772 {don't output garbage if nefarious user sets invalid month value;
773 this error message never actually shows up, the program just aborts,
774 but it doesn't matter in practice.}
775 if (month < 1) or (month > 12) then fatal_error("month out of range 1..12");
776 for k:=3*month-2 to 3*month do wlog(months[k]);
777 print_char(" "); print_int(year); print_char(" ");
778 print_two(time div 60); print_char(":"); print_two(time mod 60);
779 print_nl("Copyright (c) 1994--2000 John Plaice and Yannis Haralambous");
780 end
781 @z
782 %---------------------------------------
783 @x [32] m.595 l.11860 - Omega
784 @!dvi_buf:array[dvi_index] of eight_bits; {buffer for \.{DVI} output}
785 @y
786 @!dvi_buf:array[dvi_index] of real_eight_bits; {buffer for \.{DVI} output}
787 @z
788 %---------------------------------------
789 @x [32] m.617 l.12262 - Omega
790 print(" TeX output "); print_int(year); print_char(".");
791 @y
792 print("Omega output, Version 3.141592653--1.15, ");
793 print_int(year); print_char(".");
794 @z
795 %---------------------------------------
796 @x [32] m.617 l.12267 - Omega
797 for s:=str_start[str_ptr] to pool_ptr-1 do dvi_out(so(str_pool[s]));
798 pool_ptr:=str_start[str_ptr]; {flush the current string}
799 @y
800 for s:=str_start(str_ptr) to pool_ptr-1 do dvi_out(so(str_pool[s]));
801 pool_ptr:=str_start(str_ptr); {flush the current string}
802 @z
803 %---------------------------------------
804 @x [36] m.765 l.15021 - Omega
805 magic_offset:=str_start[math_spacing]-9*ord_noad
806 @y
807 magic_offset:=str_start(math_spacing)-9*ord_noad
808 @z
809 %---------------------------------------
810 @x [42] m.931 l.18172 - Omega
811 begin j:=1; u:=str_start[k];
812 @y
813 begin j:=1; u:=str_start(k);
814 @z
815 %---------------------------------------
816 @x [42] m.940 l.18296 - Omega
817 u:=str_start[k]; v:=str_start[s];
818 repeat if str_pool[u]<str_pool[v] then goto found;
819 if str_pool[u]>str_pool[v] then goto not_found;
820 incr(u); incr(v);
821 until u=str_start[k+1];
822 @y
823 u:=str_start(k); v:=str_start(s);
824 repeat if str_pool[u]<str_pool[v] then goto found;
825 if str_pool[u]>str_pool[v] then goto not_found;
826 incr(u); incr(v);
827 until u=str_start(k+1);
828 @z
829 %---------------------------------------
830 @x [49] m.1252 l.23232 - Omega
831 print_err("Patterns can be loaded only by INITEX");
832 @y
833 print_err("Patterns can be loaded only by INIOMEGA");
834 @z
835 %---------------------------------------
836 @x [50] m.1301 l.23682 - Omega
837 format_ident:=" (INITEX)";
838 @y
839 format_ident:=" (INIOMEGA)";
840 @z
841 %---------------------------------------
842 % We do not store any information for strings between 257 and 65535.
843
844 @x [50] m.1309 l.23814 - Omega
845 for k:=0 to str_ptr do dump_int(str_start[k]);
846 @y
847 for k:=too_big_char to str_ptr do dump_int(str_start(k));
848 @z
849 %---------------------------------------
850 % We recreate the information for strings between 257 and 65535.
851
852 @x [50] m.1310 l.23831 - Omega
853 for k:=0 to str_ptr do undump(0)(pool_ptr)(str_start[k]);
854 @y
855 for k:=too_big_char to str_ptr do undump(0)(pool_ptr)(str_start(k));
856 @z
857 %---------------------------------------
858 @x [51] m.1334 l.24266 - Omega
859 wlog_ln('Here is how much of TeX''s memory',' you used:');
860 @y
861 wlog_ln('Here is how much of Omega''s memory',' you used:');
862 @z
863 %---------------------------------------
864 @x [51] m.1335 l.24338 - Omega
865 print_nl("(\dump is performed only by INITEX)"); return;
866 @:dump_}{\.{\\dump...only by INITEX}@>
867 @y
868 print_nl("(\dump is performed only by INIOMEGA)"); return;
869 @:dump_}{\.{\\dump...only by INIOMEGA}@>
870 @z
871 %---------------------------------------
872 @x [53] m.1368 l.24747 - Omega
873 for k:=str_start[str_ptr] to pool_ptr-1 do dvi_out(so(str_pool[k]));
874 pool_ptr:=str_start[str_ptr]; {erase the string}
875 @y
876 for k:=str_start(str_ptr) to pool_ptr-1 do dvi_out(so(str_pool[k]));
877 pool_ptr:=str_start(str_ptr); {erase the string}
878 @z
879 %---------------------------------------