Debian Codegraph @

texk/web2c/tracingstacklevels.ch

raw
1 % $Id: tracingstacklevels.ch 57750 2021-02-15 09:33:12Z ascherer $
2 % Public domain. From Petr Olsak, tex-implementors 2feb2021,
3 % with adaptations by Akira Kakuto.
4 %
5 % If new parameter \tracingstacklevels>0, and \tracingmacros>0,
6 % output a prefix indicating depth of macro nesting. Also output a
7 % similar prefix for each \input (regardless of \tracingmacros), which
8 % counts as a level of input for this.
9 %
10 % Furthermore, if macro expansion is >= the \tracingstacklevels
11 % value, abbreviate the output.
12 %
13 % A simple test file is in web2c/tests; running:
14 % TEXINPUTS=/.../web2c/tests pdftex -ini tracingstacklevels.tex
15 % should result in log output like:
16 % ~.\b ->\a
17 % ~~\a
18 % ...
19 % ~.INPUT tracingstacklevel2
20 % ~~\b
21 % ...
22
23 @x
24 @d web2c_int_pars=web2c_int_base+3 {total number of web2c's integer parameters}
25 @y
26 @d tracing_stack_levels_code=web2c_int_base+3 {tracing |input_stack| level if |tracingmacros| positive}
27 @d web2c_int_pars=web2c_int_base+4 {total number of web2c's integer parameters}
28 @z
29
30 @x
31 @d tracing_char_sub_def==int_par(tracing_char_sub_def_code)
32 @y
33 @d tracing_char_sub_def==int_par(tracing_char_sub_def_code)
34 @d tracing_stack_levels==int_par(tracing_stack_levels_code)
35 @z
36
37 @x
38 tracing_char_sub_def_code:print_esc("tracingcharsubdef");
39 @y
40 tracing_char_sub_def_code:print_esc("tracingcharsubdef");
41 tracing_stack_levels_code:print_esc("tracingstacklevels");
42 @z
43
44 @x
45 primitive("tracingcharsubdef",assign_int,int_base+tracing_char_sub_def_code);@/
46 @!@:tracing_char_sub_def_}{\.{\\tracingcharsubdef} primitive@>
47 end;
48 @y
49 primitive("tracingcharsubdef",assign_int,int_base+tracing_char_sub_def_code);@/
50 @!@:tracing_char_sub_def_}{\.{\\tracingcharsubdef} primitive@>
51 end;
52 primitive("tracingstacklevels",assign_int,int_base+tracing_stack_levels_code);@/
53 @!@:tracing_stack_levels_}{\.{\\tracingstacklevels} primitive@>
54 @z
55
56 @x This is in <Tidy up the parameter...>.
57 incr(n);
58 if tracing_macros>0 then
59 @y
60 incr(n);
61 if tracing_macros>0 then
62 if (tracing_stack_levels=0) or (input_ptr<tracing_stack_levels) then
63 @z
64
65 @x \tracingstacklevels for macro expansion.
66 begin begin_diagnostic; print_ln; print_cs(warning_index);
67 token_show(ref_count); end_diagnostic(false);
68 @y
69 begin begin_diagnostic;
70 if tracing_stack_levels > 0 then
71 if input_ptr < tracing_stack_levels then
72 begin
73 v := input_ptr;
74 print_ln; print_char("~");
75 while v > 0 do
76 begin print_char("."); decr(v);
77 end;
78 print_cs(warning_index); token_show(ref_count);
79 end
80 else begin
81 print_char("~"); print_char("~"); print_cs(warning_index);
82 end
83 else begin print_ln; print_cs(warning_index); token_show(ref_count); end;
84 end_diagnostic(false);
85 @z
86
87 @x New variable in |start_input|.
88 var temp_str: str_number;
89 begin scan_file_name; {set |cur_name| to desired file name}
90 @y
91 var temp_str: str_number;
92 v: pointer;
93 begin scan_file_name; {set |cur_name| to desired file name}
94 @z
95
96 % \tracingstacklevels for \input.
97 % Still in |start_input|, after other changes from the general \.{tex.ch}.
98 @x
99 else if (term_offset>0)or(file_offset>0) then print_char(" ");
100 print_char("("); incr(open_parens);
101 slow_print(full_source_filename_stack[in_open]); update_terminal;
102 @y
103 else if (term_offset>0)or(file_offset>0) then print_char(" ");
104 print_char("("); incr(open_parens);
105 slow_print(full_source_filename_stack[in_open]); update_terminal;
106 if tracing_stack_levels > 0 then
107 begin
108 begin_diagnostic; print_ln;
109 print_char("~");
110 v := input_ptr-1;
111 if v < tracing_stack_levels then
112 while v > 0 do begin print_char("."); decr(v); end
113 else print_char("~");
114 slow_print("INPUT "); slow_print(cur_name); slow_print(cur_ext); print_ln;
115 end_diagnostic(false);
116 end;
117 @z