Debian Codegraph @

texk/web2c/luatexdir/tex/mainbody.h

raw
1 /* mainbody.h
2
3 Copyright 2009 Taco Hoekwater <[email protected]>
4
5 This file is part of LuaTeX.
6
7 LuaTeX is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2 of the License, or (at your
10 option) any later version.
11
12 LuaTeX is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 License for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
19
20
21 #ifndef MAINBODY_H
22 # define MAINBODY_H
23
24 extern int luatex_version;
25 extern int luatex_revision;
26 extern const char *luatex_version_string;
27 extern const char *engine_name;
28
29 /*
30 The following parameters can be changed at compile time to extend or
31 reduce \TeX's capacity. They may have different values in \.{INITEX} and
32 in production versions of \TeX.
33 @.INITEX@>
34 @^system dependencies@>
35 */
36
37 # define ssup_max_strings 2097151
38
39 # define inf_max_strings 100000
40 # define sup_max_strings ssup_max_strings
41 # define inf_strings_free 100
42 # define sup_strings_free sup_max_strings
43
44 # define inf_buf_size 500
45 # define sup_buf_size 100000000
46
47 # define inf_nest_size 40
48 # define sup_nest_size 4000
49
50 # define inf_max_in_open 6
51 # define sup_max_in_open 600 /* was 127. now okay for some 512 nested lua calls */
52
53 # define inf_param_size 60
54 # define sup_param_size 32767
55
56 # define inf_save_size 600
57 # define sup_save_size 500000
58
59 # define inf_stack_size 200
60 # define sup_stack_size 50000
61
62 # define inf_dvi_buf_size 800
63 # define sup_dvi_buf_size 65536
64
65 # define sup_hash_extra sup_max_strings
66 # define inf_hash_extra 0
67
68 # define inf_expand_depth 100
69 # define sup_expand_depth 10000000
70
71 # define inf_level_max 0
72 # define sup_level_max 500
73
74 # define inf_level_chr 1
75 # define sup_level_chr 126
76
77 # include <stdio.h>
78
79 /* Types in the outer block */
80 typedef int ASCII_code; /* characters */
81 typedef unsigned char eight_bits; /* unsigned one-byte quantity */
82 typedef FILE *alpha_file; /* files that contain textual data */
83 typedef FILE *byte_file; /* files that contain binary data */
84
85 typedef int str_number;
86 typedef int pool_pointer;
87 typedef unsigned char packed_ASCII_code;
88
89 typedef int scaled; /* this type is used for scaled integers */
90 typedef char small_number; /* this type is self-explanatory */
91
92 typedef float glue_ratio; /* one-word representation of a glue expansion factor */
93
94 typedef unsigned short quarterword;
95 typedef int halfword;
96
97 typedef unsigned char glue_ord; /* infinity to the 0, 1, 2, 3, or 4 power */
98
99 typedef unsigned short group_code; /* |save_level| for a level boundary */
100
101 typedef int font_index; /* index into |font_info| */
102
103 typedef int save_pointer;
104
105 /*
106 Characters of text that have been converted to \TeX's internal form
107 are said to be of type |ASCII_code|, which is a subrange of the integers.
108
109 We are assuming that our runtime system is able to read and write UTF-8.
110
111 Some of the ASCII codes without visible characters have been given symbolic
112 names in this program because they are used with a special meaning.
113 */
114
115
116 # define null_code '\0' /* ASCII code that might disappear */
117 # define carriage_return '\r' /* ASCII code used at end of line */
118
119 /* Global variables */
120 extern boolean luainit; /* are we using lua for initializations */
121 extern boolean tracefilenames; /* print file open-close info? */
122 extern boolean traceextranewline; /* extra line in tracingmacros? */
123
124
125 extern boolean ini_version; /* are we \.{INITEX}? */
126 extern boolean dump_option;
127 extern boolean dump_line;
128 extern int bound_default;
129 extern char *bound_name;
130 extern int error_line;
131 extern int half_error_line;
132 extern int max_print_line;
133 extern int max_strings;
134 extern int level_max;
135 extern int level_chr;
136 extern int strings_free;
137 extern int font_k;
138 extern int buf_size;
139 extern int stack_size;
140 extern int max_in_open;
141 extern int param_size;
142 extern int nest_size;
143 extern int save_size;
144 extern int expand_depth;
145 /*extern int parsefirstlinep;*/
146 extern int filelineerrorstylep;
147 extern int haltonerrorp;
148 extern boolean haltingonerrorp;
149 extern boolean quoted_filename;
150
151 extern int total_pages;
152 extern int check_dvi_total_pages;
153 extern int dead_cycles;
154
155 /*
156 In order to make efficient use of storage space, \TeX\ bases its major data
157 structures on a |memory_word|, which contains either a (signed) integer,
158 possibly scaled, or a (signed) |glue_ratio|, or a small number of
159 fields that are one half or one quarter of the size used for storing
160 integers.
161
162 If |x| is a variable of type |memory_word|, it contains up to four
163 fields that can be referred to as follows:
164 $$\vbox{\halign{\hfil#&#\hfil&#\hfil\cr
165 |x|&.|int|&(an |integer|)\cr
166 |x|&.|sc|\qquad&(a |scaled| integer)\cr
167 |x|&.|gr|&(a |glue_ratio|)\cr
168 |x.hh.lh|, |x.hh|&.|rh|&(two halfword fields)\cr
169 |x.hh.b0|, |x.hh.b1|, |x.hh|&.|rh|&(two quarterword fields, one halfword
170 field)\cr
171 |x.qqqq.b0|, |x.qqqq.b1|, |x.qqqq|&.|b2|, |x.qqqq.b3|\hskip-100pt
172 &\qquad\qquad\qquad(four quarterword fields)\cr}}$$
173 This is somewhat cumbersome to write, and not very readable either, but
174 macros will be used to make the notation shorter and more transparent.
175 The \PASCAL\ code below gives a formal definition of |memory_word| and
176 its subsidiary types, using packed variant records. \TeX\ makes no
177 assumptions about the relative positions of the fields within a word.
178
179 We are assuming 32-bit integers, a halfword must contain at least
180 32 bits, and a quarterword must contain at least 16 bits.
181 @^system dependencies@>
182
183 N.B.: Valuable memory space will be dreadfully wasted unless \TeX\ is compiled
184 by a \PASCAL\ that packs all of the |memory_word| variants into
185 the space of a single integer. This means, for example, that |glue_ratio|
186 words should be |short_real| instead of |real| on some computers. Some
187 \PASCAL\ compilers will pack an integer whose subrange is `|0..255|' into
188 an eight-bit field, but others insist on allocating space for an additional
189 sign bit; on such systems you can get 256 values into a quarterword only
190 if the subrange is `|-128..127|'.
191
192 The present implementation tries to accommodate as many variations as possible,
193 so it makes few assumptions. If integers having the subrange
194 `|min_quarterword..max_quarterword|' can be packed into a quarterword,
195 and if integers having the subrange `|min_halfword..max_halfword|'
196 can be packed into a halfword, everything should work satisfactorily.
197
198 It is usually most efficient to have |min_quarterword=min_halfword=0|,
199 so one should try to achieve this unless it causes a severe problem.
200 The values defined here are recommended for most 32-bit computers.
201
202 We cannot use the full range of 32 bits in a halfword, because we have
203 to allow negative values for potential backend tricks like web2c's
204 dynamic allocation, and parshapes pointers have to be able to store at
205 least twice the value |max_halfword| (see below). Therefore,
206 |max_halfword| is $2^{30}-1$
207 */
208
209 # include "tex/memoryword.h"
210
211 # define min_quarterword 0 /*smallest allowable value in a |quarterword| */
212 # define max_quarterword 65535 /* largest allowable value in a |quarterword| */
213 # define min_halfword -0x3FFFFFFF /* smallest allowable value in a |halfword| */
214 # define max_halfword 0x3FFFFFFF
215 /* largest allowable value in a |halfword| */
216
217
218 /*
219 The following procedure, which is called just before \TeX\ initializes its
220 input and output, establishes the initial values of the date and time.
221 It calls a macro-defined |dateandtime| routine. |dateandtime| in turn is
222 also a C macro, which calls |get_date_and_time|, passing it the addresses of
223 the day, month, etc., so they can be set by the routine.
224 |get_date_and_time| also sets up interrupt catching if that
225 is conditionally compiled in the C code.
226 @^system dependencies@>
227 */
228
229 # define fix_date_and_time() dateandtime(time_par,day_par,month_par,year_par)
230
231 extern int get_luatexversion(void);
232 extern str_number get_luatexrevision(void);
233
234 extern int ready_already;
235
236 extern void main_body(void);
237 extern void close_files_and_terminate(void);
238
239 extern void final_cleanup(void);
240 extern void debug_help(void); /* routine to display various things */
241
242 extern int main_initialize(void);
243
244 /* lazy me */
245 # define get_cur_font() equiv(cur_font_loc)
246 # define zset_cur_font set_cur_font
247
248
249 #endif