3 % Copyright
2009-2010 Taco Hoekwater
<taco@@luatex.org
>
5 % This file is part of LuaTeX.
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.
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.
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
/>.
30 pdfTeX is copyright
(C
) 1996-2006 Han The Thanh
, <thanh@@pdftex.org
>.
32 e-TeX is copyright
(C
) 1994,98 by Peter Breitenlohner.
34 This is LuaTeX
, a continuation of $\pdfTeX$ and $\Aleph$. LuaTeX is a
35 document compiler intended to simplify high-quality typesetting for
36 many of the world's languages. It is an extension of D. E. Knuth's
37 \TeX
, which was designed essentially for the typesetting of languages
38 using the Latin alphabet.
40 The $\Aleph$ subsystem loosens many of the restrictions imposed by~\TeX
:
41 register numbers are no longer limited to
8~bits
; fonts may have more
42 than
256~characters
; more than
256~fonts may be used
; etc.
44 % This program is directly derived from Donald E. Knuth's TeX
;
45 % the change history which follows and the reward offered for finders of
46 % bugs refer specifically to TeX
; they should not be taken as referring
47 % to LuaTeX
, pdfTeX
, nor e-TeX
, although the change history is relevant in that it
48 % demonstrates the evolutionary path followed. This program is not TeX
;
49 % that name is reserved strictly for the program which is the creation
50 % and sole responsibility of Professor Knuth.
52 % Version
0 was released in September
1982 after it passed a variety of tests.
53 % Version
1 was released in November
1983 after thorough testing.
54 % Version
1.1 fixed ``disappearing font identifiers'' et alia
(July
1984).
55 % Version
1.2 allowed `
0' in response to an error
, et alia
(October
1984).
56 % Version
1.3 made memory allocation more flexible and local
(November
1984).
57 % Version
1.4 fixed accents right after line breaks
, et alia
(April
1985).
58 % Version
1.5 fixed \the\toks after other expansion in \edefs
(August
1985).
59 % Version
2.0 (almost identical to
1.5) corresponds to
"Volume B" (April
1986).
60 % Version
2.1 corrected anomalies in discretionary breaks
(January
1987).
61 % Version
2.2 corrected
"(Please type...)" with null \endlinechar
(April
1987).
62 % Version
2.3 avoided incomplete page in premature termination
(August
1987).
63 % Version
2.4 fixed \noaligned rules in indented displays
(August
1987).
64 % Version
2.5 saved cur_order when expanding tokens
(September
1987).
65 % Version
2.6 added
10sp slop when shipping leaders
(November
1987).
66 % Version
2.7 improved rounding of negative-width characters
(November
1987).
67 % Version
2.8 fixed weird bug if no \patterns are used
(December
1987).
68 % Version
2.9 made \csname\endcsname's
"relax" local
(December
1987).
69 % Version
2.91 fixed \outer\def\a0
{}\a\a bug
(April
1988).
70 % Version
2.92 fixed \patterns
, also file names with complex macros
(May
1988).
71 % Version
2.93 fixed negative halving in allocator when mem_min
<0 (June
1988).
72 % Version
2.94 kept open_log_file from calling fatal_error
(November
1988).
73 % Version
2.95 solved that problem a better way
(December
1988).
74 % Version
2.96 corrected bug in
"Infinite shrinkage" recovery
(January
1989).
75 % Version
2.97 corrected blunder in creating
2.95 (February
1989).
76 % Version
2.98 omitted save_for_after at outer level
(March
1989).
77 % Version
2.99 caught $$\begingroup\halign..$$
(June
1989).
78 % Version
2.991 caught
.5\ifdim
.6...
(June
1989).
79 % Version
2.992 introduced major changes for
8-bit extensions
(September
1989).
80 % Version
2.993 fixed a save_stack synchronization bug et alia
(December
1989).
81 % Version
3.0 fixed unusual displays
; was more \output robust
(March
1990).
82 % Version
3.1 fixed nullfont
, disabled \write
{\the\prevgraf
} (September
1990).
83 % Version
3.14 fixed unprintable font names and corrected typos
(March
1991).
84 % Version
3.141 more of same
; reconstituted ligatures better
(March
1992).
85 % Version
3.1415 preserved nonexplicit kerns
, tidied up
(February
1993).
86 % Version
3.14159 allowed fontmemsize to change
; bulletproofing
(March
1995).
87 % Version
3.141592 fixed \xleaders
, glueset
, weird alignments
(December
2002).
88 % Version
3.1415926 was a general cleanup with minor fixes
(February
2008).
91 % Although considerable effort has been expended to make the LuaTeX program
92 % correct and reliable
, no warranty is implied
; the authors disclaim any
93 % obligation or liability for damages
, including but not limited to
94 % special
, indirect
, or consequential damages arising out of or in
95 % connection with the use or performance of this software. This work has
96 % been a ``labor of love'' and the authors hope that users enjoy it.
98 A large piece of software like \TeX\ has inherent complexity that cannot
99 be reduced below a certain level of difficulty
, although each individual
100 part is fairly simple by itself. The \.
{WEB
} language is intended to make
101 the algorithms as readable as possible
, by reflecting the way the
102 individual program pieces fit together and by providing the
103 cross-references that connect different parts. Detailed comments about
104 what is going on
, and about why things were done in certain ways
, have
105 been liberally sprinkled throughout the program. These comments explain
106 features of the implementation
, but they rarely attempt to explain the
107 \TeX\ language itself
, since the reader is supposed to be familiar with
110 @
:TeXbook
}{\sl The \TeX book@
>
112 The present implementation has a long ancestry
, beginning in the summer
113 of
~1977
, when Michael~F. Plass and Frank~M. Liang designed and coded
115 @^Plass
, Michael Frederick@
>
116 @^Liang
, Franklin Mark@
>
117 @^Knuth
, Donald Ervin@
>
118 based on some specifications that the author had made in May of that year.
119 This original proto\TeX\ included macro definitions and elementary
120 manipulations on boxes and glue
, but it did not have line-breaking
,
121 page-breaking
, mathematical formulas
, alignment routines
, error recovery
,
122 or the present semantic nest
; furthermore
,
123 it used character lists instead of token lists
, so that a control sequence
124 like \.
{\\halign
} was represented by a list of seven characters. A
125 complete version of \TeX\ was designed and coded by the author in late
126 1977 and early
1978; that program
, like its prototype
, was written in the
127 {\mc SAIL
} language
, for which an excellent debugging system was
128 available. Preliminary plans to convert the
{\mc SAIL
} code into a form
129 somewhat like the present ``web'' were developed by Luis Trabb~Pardo and
130 @^Trabb Pardo
, Luis Isidoro@
>
131 the author at the beginning of
1979, and a complete implementation was
132 created by Ignacio~A. Zabala in
1979 and
1980. The \TeX82 program
, which
133 @^Zabala Salelles
, Ignacio Andr\'es@
>
134 was written by the author during the latter part of
1981 and the early
135 part of
1982, also incorporates ideas from the
1979 implementation of
136 @^Guibas
, Leonidas Ioannis@
>
137 @^Sedgewick
, Robert@
>
138 @^Wyatt
, Douglas Kirk@
>
139 \TeX\ in
{\mc MESA
} that was written by Leonidas Guibas
, Robert Sedgewick
,
140 and Douglas Wyatt at the Xerox Palo Alto Research Center. Several hundred
141 refinements were introduced into \TeX82 based on the experiences gained with
142 the original implementations
, so that essentially every part of the system
143 has been substantially improved. After the appearance of ``Version
0'' in
144 September
1982, this program benefited greatly from the comments of
145 many other people
, notably David~R. Fuchs and Howard~W. Trickey.
146 A final revision in September
1989 extended the input character set to
147 eight-bit codes and introduced the ability to hyphenate words from
148 different languages
, based on some ideas of Michael~J. Ferguson.
149 @^Fuchs
, David Raymond@
>
150 @^Trickey
, Howard Wellington@
>
151 @^Ferguson
, Michael John@
>
153 No doubt there still is plenty of room for improvement
, but the author
154 is firmly committed to keeping \TeX82 ``frozen'' from now on
; stability
155 and reliability are to be its main virtues.
157 On the other hand
, the \.
{WEB
} description can be extended without changing
158 the core of \TeX82 itself
, and the program has been designed so that such
159 extensions are not extremely difficult to make.
160 The |banner| string defined here should be changed whenever \TeX\
161 undergoes any modifications
, so that it will be clear which version of
162 \TeX\ might be the guilty party when a problem arises.
163 @^extensions to \TeX@
>
164 @^system dependencies@
>
166 This program contains code for various features extending \TeX
,
167 therefore this program is called `\eTeX' and not
168 `\TeX'
; the official name `\TeX' by itself is reserved
169 for software systems that are fully compatible with each other.
170 A special test suite called the ``\.
{TRIP
} test'' is available for
171 helping to determine whether a particular implementation deserves to be
172 known as `\TeX'
[cf.~Stanford Computer Science report CS1027
,
175 A similar test suite called the ``\.
{e-TRIP
} test'' is available for
176 helping to determine whether a particular implementation deserves to be
179 @ This is the first of many sections of \TeX\ where global variables are
183 boolean luainit
; /* are we using lua for initializations
*/
184 boolean tracefilenames
; /* print file open-close info?
*/
187 @ This program has two important variations
: (1) There is a long and slow
188 version called \.
{INITEX
}, which does the extra calculations needed to
190 initialize \TeX's internal tables
; and
(2)~there is a shorter and faster
191 production version
, which cuts the initialization to a bare minimum.
194 boolean ini_version
; /* are we \.
{INITEX
}?
*/
195 boolean dump_option
; /* was the dump name option used?
*/
196 boolean dump_line
; /* was a \.
{\
%\AM format
} line seen?
*/
197 int bound_default
; /* temporary for setup
*/
198 char
*bound_name
; /* temporary for setup
*/
199 int error_line
; /* width of context lines on terminal error messages
*/
200 int half_error_line
; /* width of first lines of contexts in terminal
201 error messages
; should be between
30 and |error_line-15|
*/
202 int max_print_line
; /* width of longest text lines output
; should be at least
60 */
203 int max_strings
; /* maximum number of strings
; must not exceed |max_halfword|
*/
204 int strings_free
; /* strings available after format loaded
*/
205 int font_k
; /* loop variable for initialization
*/
206 int buf_size
; /* maximum number of characters simultaneously present in
207 current lines of open files and in control sequences between
208 \.
{\\csname
} and \.
{\\endcsname
}; must not exceed |max_halfword|
*/
209 int stack_size
; /* maximum number of simultaneous input sources
*/
210 int max_in_open
; /* maximum number of input files and error insertions that
211 can be going on simultaneously
*/
212 int param_size
; /* maximum number of simultaneous macro parameters
*/
213 int nest_size
; /* maximum number of semantic levels simultaneously active
*/
214 int save_size
; /* space for saving values outside of current group
; must be
215 at most |max_halfword|
*/
216 int expand_depth
; /* limits recursive calls of the |expand| procedure
*/
217 int parsefirstlinep
; /* parse the first line for options
*/
218 int filelineerrorstylep
; /* format messages as file
:line
:error
*/
219 int haltonerrorp
; /* stop at first error
*/
220 boolean quoted_filename
; /* current filename is quoted
*/
223 int get_luatexversion
(void
)
225 return luatex_version
;
228 str_number get_luatexrevision
(void
)
230 return luatex_revision
;
233 int get_luatex_date_info
(void
)
235 return luatex_date_info
; /* todo
, silly value
*/
239 @ This is it
: the part of \TeX\ that executes all those procedures we have
242 We have noted that there are two versions of \TeX82. One
, called \.
{INITEX
},
244 has to be run first
; it initializes everything from scratch
, without
245 reading a format file
, and it has the capability of dumping a format file.
246 The other one is called `\.
{VIRTEX
}'
; it is a ``virgin'' program that needs
248 to input a format file in order to get started.
251 #define const_chk
(A
) do
{ \
252 if
(A
< inf_##A
) A
= inf_##A
; \
253 if
(A
> sup_##A
) A
= sup_##A
; \
256 #define setup_bound_var
(A
,B
,C
) do
{ \
258 get_lua_number
("texconfig",B
,&C); \
262 setupboundvariable
(&x, B, A); \
268 int ready_already
= 0;
270 int main_initialize
(void
)
272 /* In case somebody has inadvertently made bad settings of the ``constants
,''
273 \LuaTeX\ checks them using a variable called |bad|.
*/
275 /* Bounds that may be set from the configuration file. We want the user to
276 be able to specify the names with underscores
, but \.
{TANGLE
} removes
277 underscores
, so we're stuck giving the names twice
, once as a string
,
278 once as the identifier. How ugly.
*/
280 setup_bound_var
(15000, "max_strings", max_strings
);
281 setup_bound_var
(100, "strings_free", strings_free
);
282 setup_bound_var
(3000, "buf_size", buf_size
);
283 setup_bound_var
(50, "nest_size", nest_size
);
284 setup_bound_var
(15, "max_in_open", max_in_open
);
285 setup_bound_var
(60, "param_size", param_size
);
286 setup_bound_var
(4000, "save_size", save_size
);
287 setup_bound_var
(300, "stack_size", stack_size
);
288 setup_bound_var
(16384, "dvi_buf_size", dvi_buf_size
);
289 setup_bound_var
(79, "error_line", error_line
);
290 setup_bound_var
(50, "half_error_line", half_error_line
);
291 setup_bound_var
(79, "max_print_line", max_print_line
);
292 setup_bound_var
(0, "hash_extra", hash_extra
);
293 setup_bound_var
(72, "pk_dpi", pk_dpi
);
294 setup_bound_var
(10000, "expand_depth", expand_depth
);
296 /* Check other constants against their sup and inf.
*/
298 const_chk
(nest_size
);
299 const_chk
(max_in_open
);
300 const_chk
(param_size
);
301 const_chk
(save_size
);
302 const_chk
(stack_size
);
303 const_chk
(dvi_buf_size
);
304 const_chk
(max_strings
);
305 const_chk
(strings_free
);
306 const_chk
(hash_extra
);
308 if
(error_line
> ssup_error_line
)
309 error_line
= ssup_error_line
;
311 /* array memory allocation
*/
312 buffer
= xmallocarray
(packed_ASCII_code
, (unsigned
) buf_size
);
313 nest
= xmallocarray
(list_state_record
, (unsigned
) nest_size
);
314 save_stack
= xmallocarray
(save_record
, (unsigned
) save_size
);
315 input_stack
= xmallocarray
(in_state_record
, (unsigned
) stack_size
);
316 input_file
= xmallocarray
(alpha_file
, (unsigned
) max_in_open
);
317 input_file_callback_id
= xmallocarray
(int
, (unsigned
) max_in_open
);
318 line_stack
= xmallocarray
(int
, (unsigned
) max_in_open
);
319 eof_seen
= xmallocarray
(boolean
, (unsigned
) max_in_open
);
320 grp_stack
= xmallocarray
(save_pointer
, (unsigned
) max_in_open
);
321 if_stack
= xmallocarray
(pointer
, (unsigned
) max_in_open
);
322 source_filename_stack
= xmallocarray
(str_number
, (unsigned
) max_in_open
);
323 full_source_filename_stack
= xmallocarray
(char
*, (unsigned
) max_in_open
);
324 param_stack
= xmallocarray
(halfword
, (unsigned
) param_size
);
325 dvi_buf
= xmallocarray
(eight_bits
, (unsigned
) dvi_buf_size
);
328 fixmem
= xmallocarray
(smemory_word
, fix_mem_init
+ 1);
329 memset
(voidcast
(fixmem
), 0, (fix_mem_init
+ 1) * sizeof
(smemory_word
));
331 fix_mem_max
= fix_mem_init
;
332 eqtb_top
= eqtb_size
+ hash_extra
;
334 hash_top
= undefined_control_sequence
;
337 hash
= xmallocarray
(two_halves
, (unsigned
) (hash_top
+ 1));
338 memset
(hash
, 0, sizeof
(two_halves
) * (unsigned
) (hash_top
+ 1));
339 eqtb
= xmallocarray
(memory_word
, (unsigned
) (eqtb_top
+ 1));
340 memset
(eqtb
, 0, sizeof
(memory_word
) * (unsigned
) (eqtb_top
+ 1));
341 init_string_pool_array
((unsigned
) max_strings
);
344 /* Check the ``constant'' values...
*/
345 if
((half_error_line
< 30) ||
(half_error_line
> error_line
- 15))
347 if
(max_print_line
< 60)
349 if
(dvi_buf_size
% 8 != 0)
351 if
(hash_prime
> hash_size
)
353 if
(max_in_open
>= 128)
355 /* Here are the inequalities that the quarterword and halfword values
356 must satisfy
(or rather
, the inequalities that they mustn't satisfy
): */
357 if
((min_quarterword
> 0) ||
(max_quarterword
< 0x7FFF))
359 if
((min_halfword
> 0) ||
(max_halfword
< 0x3FFFFFFF))
361 if
((min_quarterword
< min_halfword
) ||
(max_quarterword
> max_halfword
))
363 if
(font_base
< min_quarterword
)
365 if
((save_size
> max_halfword
) ||
(max_strings
> max_halfword
))
367 if
(buf_size
> max_halfword
)
369 if
(max_quarterword
- min_quarterword
< 0xFFFF)
371 if
(cs_token_flag
+ eqtb_size
+ hash_extra
> max_halfword
)
376 "Ouch---my internal constants have been clobbered! ---case %d",
379 initialize
(); /* set global variables to their starting values
*/
381 /* initialize all the primitives
*/
382 no_new_control_sequence
= false
;
384 initialize_commands
();
385 initialize_etex_commands
();
386 init_str_ptr
= str_ptr
;
387 no_new_control_sequence
= true
;
390 ready_already
= 314159;
398 static char pdftex_map
[] = "pdftex.map";
399 int bad
= main_initialize
();
400 history
= fatal_error_stop
; /* in case we quit during initialization
*/
401 t_open_out
(); /* open the terminal for output
*/
403 tracefilenames
= true
;
407 print_banner
(luatex_version_string
);
409 /* Get the first line of input and prepare to start
*/
410 /* When we begin the following code
, \TeX's tables may still contain garbage
;
411 the strings might not even be present. Thus we must proceed cautiously to get
414 But when we finish this part of the program
, \TeX\ is ready to call on the
415 |main_control| routine to do its work.
417 initialize_inputstack
(); /* this copies the command-line
*/
418 if
(buffer
[iloc
] == '
*'
)
420 if
((format_ident
== 0) ||
(buffer
[iloc
] == '
&') || dump_line) {
422 if
(format_ident
!= 0 && !ini_version)
423 initialize
(); /* erase preloaded format
*/
424 if
((fname
= open_fmt_file
()) == NULL)
426 if
(!load_fmt_file
(fname
)) {
431 while
((iloc
< ilimit
) && (buffer[iloc] == ' '))
434 if
(output_mode_option
!= 0)
435 int_par
(output_mode_code
) = output_mode_value
;
436 if
(draft_mode_option
!= 0) {
437 int_par
(draft_mode_code
) = draft_mode_value
;
439 /* can this be moved?
*/
440 pdf_init_map_file
((char
*) pdftex_map
);
442 if
(end_line_char_inactive
)
445 buffer
[ilimit
] = (packed_ASCII_code
) int_par
(end_line_char_code
);
447 random_seed
= (microseconds
* 1000) + (epochseconds
% 1000000);
448 init_randoms
(random_seed
);
450 fixup_selector
(log_opened_global
);
451 check_texconfig_init
();
452 if
((iloc
< ilimit
) && (get_cat_code(int_par(cat_code_table_code),
453 buffer
[iloc
]) != escape_cmd
))
454 start_input
(); /* \.
{\\input
} assumed
*/
455 /* DIR: Initialize |text_dir_ptr|
*/
456 text_dir_ptr
= new_dir
(0);
458 history
= spotless
; /* ready to go
! */
459 /* Initialize synctex primitive
*/
460 synctexinitcommand
();
461 main_control
(); /* come to life
*/
462 flush_node
(text_dir_ptr
);
463 final_cleanup
(); /* prepare for death
*/
464 close_files_and_terminate
();
470 @ Here we do whatever is needed to complete \TeX's job gracefully on the
471 local operating system. The code here might come into play after a fatal
472 error
; it must therefore consist entirely of ``safe'' operations that
473 cannot produce error messages. For example
, it would be a mistake to call
474 |str_room| or |make_string| at this time
, because a call on |overflow|
475 might lead to an infinite loop.
476 @^system dependencies@
>
478 Actually there's one way to get error messages
, via |prepare_mag|
;
479 but that can't cause infinite recursion.
482 This program doesn't bother to close the input files that may still be open.
485 void close_files_and_terminate
(void
)
488 callback_id
= callback_defined
(stop_run_callback
);
489 finalize_write_files
();
490 if
(int_par
(tracing_stats_code
) > 0) {
491 if
(callback_id
== 0) {
492 /* Output statistics about this job
*/
493 /* The present section goes directly to the log file instead of using
494 |print| commands
, because there's no need for these strings to take
495 up |string_pool| memory when a non-
{\bf stat
} version of \TeX\ is being used.
498 if
(log_opened_global
) {
500 "\n\nHere is how much of LuaTeX's memory you used:\n");
501 fprintf
(log_file
, " %d string%s out of %d\n",
502 (int
) (str_ptr
- init_str_ptr
),
503 (str_ptr
== (init_str_ptr
+ 1) ?
"" : "s"),
504 (int
) (max_strings
- init_str_ptr
+ STRING_OFFSET
));
505 fprintf
(log_file
, " %d,%d words of node,token memory allocated",
506 (int
) var_mem_max
, (int
) fix_mem_max
);
507 print_node_mem_stats
();
509 " %d multiletter control sequences out of %ld+%d\n",
510 (int
) cs_count
, (long
) hash_size
, (int
) hash_extra
);
511 fprintf
(log_file
, " %d font%s using %d bytes\n",
512 (int
) max_font_id
(), (max_font_id
() == 1 ?
"" : "s"),
515 " %di,%dn,%dp,%db,%ds stack positions out of %di,%dn,%dp,%db,%ds\n",
516 (int
) max_in_stack
, (int
) max_nest_stack
,
517 (int
) max_param_stack
, (int
) max_buf_stack
,
518 (int
) max_save_stack
+ 6, (int
) stack_size
,
519 (int
) nest_size
, (int
) param_size
, (int
) buf_size
,
525 /* rubish
, these pdf arguments
, passed
, needs to be fixed
, e.g. with a dummy in dvi
*/
527 /* Close
{\sl Sync\TeX
} file and write status
*/
528 synctexterminate
(log_opened_global
); /* Let the
{\sl Sync\TeX
} controller close its files.
*/
531 if
(log_opened_global
) {
533 selector
= selector
- 2;
534 if
((selector
== term_only
) && (callback_id == 0)) {
535 tprint_nl
("Transcript written on ");
536 tprint_file_name
(NULL, texmf_log_name
, NULL);
540 lua_a_close_out
(log_file
);
545 @ We get to the |final_cleanup| routine when \.
{\\end
} or \.
{\\dump
} has
546 been scanned and |its_all_over|\kern-2pt.
549 void final_cleanup
(void
)
551 int c
; /* 0 for \.
{\\end
}, 1 for \.
{\\dump
} */
552 halfword i
; /* for looping marks
*/
556 while
(input_ptr
> 0)
557 if
(istate
== token_list
)
561 while
(open_parens
> 0) {
562 report_stop_file
(filetype_tex
);
565 if
(cur_level
> level_one
) {
566 tprint_nl
("(\\end occurred inside a group at level ");
567 print_int
(cur_level
- level_one
);
571 while
(cond_ptr
!= null
) {
572 tprint_nl
("(\\end occurred when ");
573 print_cmd_chr
(if_test_cmd
, cur_if
);
578 tprint
(" was incomplete)");
579 if_line
= if_line_field
(cond_ptr
);
580 cur_if
= subtype
(cond_ptr
);
582 cond_ptr
= vlink
(cond_ptr
);
583 flush_node
(temp_ptr
);
585 if
(callback_defined
(stop_run_callback
) == 0)
586 if
(history
!= spotless
)
587 if
((history
== warning_issued
) ||
(interaction
< error_stop_mode
))
588 if
(selector
== term_and_log
) {
589 selector
= term_only
;
591 ("(see the transcript file for additional information)");
592 selector
= term_and_log
;
596 for
(i
= 0; i
<= biggest_used_mark
; i
++) {
598 delete_first_mark
(i
);
600 delete_split_first_mark
(i
);
601 delete_split_bot_mark
(i
);
603 for
(c
= last_box_code
; c
<= vsplit_code
; c
++)
604 flush_node_list
(disc_ptr
[c
]);
605 if
(last_glue
!= max_halfword
)
606 delete_glue_ref
(last_glue
);
607 while
(pseudo_files
!= null
)
608 pseudo_close
(); /* flush pseudo files
*/
612 tprint_nl
("(\\dump is performed only by INITEX)");
617 @ Once \TeX\ is working
, you should be able to diagnose most errors with
618 the \.
{\\show
} commands and other diagnostic features.
619 An additional routine called |debug_help|
620 will come into play when you type `\.D' after an error message
;
621 |debug_help| also occurs just before a fatal error causes \TeX\ to succumb.
623 @^system dependencies@
>
625 The interface to |debug_help| is primitive
, but it is good enough when used
626 with a debugger that allows you to set breakpoints and to read
627 variables and change their values. After getting the prompt `\.
{debug \#
}'
, you
628 type either a negative number
(this exits |debug_help|
), or zero
(this
629 goes to a location where you can set a breakpoint
, thereby entering into
630 dialog with the debugger
), or a positive number |m| followed by
631 an argument |n|. The meaning of |m| and |n| will be clear from the
632 program below.
(If |m
=13|
, there is an additional argument
, |l|.
)
637 void debug_help
(void
)
638 { /* routine to display various things
*/
640 int m
= 0, n
= 0, l
= 0;
643 tprint_nl
("debug # (-1 to exit):");
645 (void
) fscanf
(term_in
, "%d", &m);
649 abort
(); /* go to every label at least once
*/
651 (void
) fscanf
(term_in
, "%d", &n);
654 print_word
(varmem
[n
]); /* display |varmem
[n
]| in all forms
*/
666 print_int
(save_type
(n
));
667 print_int
(save_level
(n
));
668 print_word
(save_word
(n
));
671 show_box
(n
); /* show a box
, abbreviated by |show_box_depth| and |show_box_breadth|
*/
675 depth_threshold
= 0x7FFFFFFF;
676 show_node_list
(n
); /* show a box in its entirety
*/
679 show_token_list
(n
, null
, 1000);
685 (void
) fscanf
(term_in
, "%d", &l);
689 for
(k
= 0; k
<= n
; k
++)
693 font_in_short_display
= null_font
;