Debian Codegraph @

texk/web2c/tex-binpool.ch

raw
1 %
2 % pool in binary
3 %
4 @x
5 @!m,@!n:text_char; {characters input from |pool_file|}
6 @!g:str_number; {garbage}
7 @!a:integer; {accumulator for check sum}
8 @!c:boolean; {check sum has been checked}
9 @y
10 @!g:str_number; {garbage}
11 @z
12 @x
13 @ @d bad_pool(#)==begin wake_up_terminal; write_ln(term_out,#);
14 a_close(pool_file); get_strings_started:=false; return;
15 end
16 @<Read the other strings...@>=
17 name_length := strlen (pool_name);
18 name_of_file := xmalloc_array (ASCII_code, name_length + 1);
19 strcpy (stringcast(name_of_file+1), pool_name); {copy the string}
20 if a_open_in (pool_file, kpse_texpool_format) then
21 begin c:=false;
22 repeat @<Read one string, but return |false| if the
23 string memory space is getting too tight for comfort@>;
24 until c;
25 a_close(pool_file); get_strings_started:=true;
26 end
27 else bad_pool('! I can''t read ', pool_name, '; bad path?')
28 @.I can't read TEX.POOL@>
29
30 @ @<Read one string...@>=
31 begin if eof(pool_file) then bad_pool('! ', pool_name, ' has no check sum.');
32 @.TEX.POOL has no check sum@>
33 read(pool_file,m); read(pool_file,n); {read two digits of string length}
34 if m='*' then @<Check the pool check sum@>
35 else begin if (xord[m]<"0")or(xord[m]>"9")or@|
36 (xord[n]<"0")or(xord[n]>"9") then
37 bad_pool('! ', pool_name, ' line doesn''t begin with two digits.');
38 @.TEX.POOL line doesn't...@>
39 l:=xord[m]*10+xord[n]-"0"*11; {compute the length}
40 if pool_ptr+l+string_vacancies>pool_size then
41 bad_pool('! You have to increase POOLSIZE.');
42 @.You have to increase POOLSIZE@>
43 for k:=1 to l do
44 begin if eoln(pool_file) then m:=' '@+else read(pool_file,m);
45 append_char(xord[m]);
46 end;
47 read_ln(pool_file); g:=make_string;
48 end;
49 end
50
51 @ The \.{WEB} operation \.{@@\$} denotes the value that should be at the
52 end of this \.{TEX.POOL} file; any other value means that the wrong pool
53 file has been loaded.
54 @^check sum@>
55
56 @<Check the pool check sum@>=
57 begin a:=0; k:=1;
58 loop@+ begin if (xord[n]<"0")or(xord[n]>"9") then
59 bad_pool('! ', pool_name, ' check sum doesn''t have nine digits.');
60 @.TEX.POOL check sum...@>
61 a:=10*a+xord[n]-"0";
62 if k=9 then goto done;
63 incr(k); read(pool_file,n);
64 end;
65 done: if a<>@$ then
66 bad_pool('! ', pool_name, ' doesn''t match; tangle me again (or fix the path).');
67 @.TEX.POOL doesn't match@>
68 c:=true;
69 end
70 @y
71 @ @<Read the other strings...@>=
72 g := loadpoolstrings((pool_size-string_vacancies));
73 if g=0 then begin
74 wake_up_terminal; write_ln(term_out,'! You have to increase POOLSIZE.');
75 get_strings_started:=false;
76 return;
77 end;
78 get_strings_started:=true;
79
80 @ Empty module
81
82 @ Empty module
83 @z