1 /* Copyright 2014 Clerk Ma
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 void give_err_help (void)
28 boolean open_fmt_file (void)
34 if (buffer[loc] == '&' || buffer[loc] == '+')
40 while (buffer[j] != ' ')
43 pack_buffered_name(0, loc, j - 1);
45 if (w_open_in(fmt_file))
49 printf("%s;%s\n", "Sorry, I can't find that format", " will try the default.");
52 name_of_file[name_length + 1] = '\0';
53 printf("%s (%s);%s\n", "Sorry, I can't find that format",
54 name_of_file + 1, " will try the default.");
55 name_of_file[name_length + 1] = ' ';
56 printf("(Perhaps your %s environment variable is not set correctly)\n",
63 pack_buffered_name(format_default_length - 4, 1, 0);
65 if (!w_open_in(fmt_file))
68 printf("%s!\n", "I can't find the default format file");
71 name_of_file[name_length + 1] = '\0';
72 printf("%s (%s)!\n", "I can't find the default format file", name_of_file + 1);
73 name_of_file[name_length + 1] = ' ';
74 printf("(Perhaps your %s environment variable is not set correctly)\n", "TEXFORMATS");
86 void close_files_and_terminate (void)
92 puts("close_files_and_terminated() already ");
97 puts("\nclose_files_and_terminate() ");
99 for (k = 0; k <= 15; k++)
101 a_close(write_file[k]);
104 if (tracing_stats > 0 || verbose_flag != 0)
107 fprintf(log_file, "%c\n", ' ');
108 fprintf(log_file, "\n");
109 fprintf(log_file, "%s%s\n", "Here is how much of TeX's memory", " you used:");
110 fprintf(log_file, "%c%lld%s", ' ', (integer)(str_ptr - init_str_ptr), " string");
112 if (str_ptr != init_str_ptr + 1)
115 #ifdef ALLOCATESTRING
117 fprintf(log_file, "%s%d\n", " out of ", (int)(current_max_strings - init_str_ptr));
120 fprintf(log_file, "%s%d\n", " out of ", (int)(max_strings - init_str_ptr));
122 #ifdef ALLOCATESTRING
124 fprintf(log_file, "%c%lld%s%lld\n", ' ', (integer)(pool_ptr - init_pool_ptr), " string characters out of ", current_pool_size - init_pool_ptr);
127 fprintf(log_file, "%c%lld%s%lld\n", ' ', (integer)(pool_ptr - init_pool_ptr), " string characters out of ", pool_size - init_pool_ptr);
131 fprintf(log_file, "%c%lld%s%d\n", ' ', (integer)(lo_mem_max - mem_min + mem_end - hi_mem_min + 2), " words of memory out of ", current_mem_size);
134 fprintf(log_file, "%c%lld%s%lld\n", ' ', (integer)(lo_mem_max - mem_min + mem_end - hi_mem_min + 2), " words of memory out of ", mem_end + 1 - mem_min);
136 fprintf(log_file, "%c%lld%s%d\n", ' ', (cs_count), " multiletter control sequences out of ", (hash_size + hash_extra));
137 fprintf(log_file, "%c%lld%s%lld%s", ' ', (fmem_ptr), " words of font info for ", (font_ptr - font_base), " font");
144 fprintf(log_file, "%s%d%s%d\n", ", out of ", current_font_mem_size, " for ", font_max - font_base);
147 fprintf(log_file, "%s%lu%s%d\n", ", out of ", font_mem_size, " for ", font_max - font_base);
149 fprintf(log_file, "%c%lld%s", ' ', hyph_count, " hyphenation exception");
154 fprintf(log_file, "%s%lld\n", " out of ", hyphen_prime);
155 fprintf(log_file, " ");
156 fprintf(log_file, "%d%s", (int) max_in_stack, "i,");
157 fprintf(log_file, "%d%s", (int) max_nest_stack, "n,");
158 fprintf(log_file, "%d%s", (int) max_param_stack, "p,");
159 fprintf(log_file, "%d%s", (int) max_buf_stack + 1, "b,");
160 fprintf(log_file, "%d%s", (int) max_save_stack + 6, "s");
161 fprintf(log_file, " stack positions out of ");
163 #ifdef ALLOCATESAVESTACK
165 fprintf(log_file, "%d%s", current_stack_size, "i,");
168 fprintf(log_file, "%d%s", stack_size, "i,");
170 #ifdef ALLOCATENESTSTACK
172 fprintf(log_file, "%d%s", current_nest_size, "n,");
175 fprintf(log_file, "%d%s", nest_size, "n,");
177 #ifdef ALLOCATEPARAMSTACK
179 fprintf(log_file, "%d%s", current_param_size, "p,");
182 fprintf(log_file, "%d%s", param_size, "p,");
184 #ifdef ALLOCATEBUFFER
186 fprintf(log_file, "%d%s", current_buf_size, "b,");
189 fprintf(log_file, "%ld%s", buf_size, "b,");
191 #ifdef ALLOCATESAVESTACK
193 fprintf(log_file, "%d%s", current_save_size, "s");
196 fprintf(log_file, "%d%s", save_size, "s");
198 fprintf(log_file, "\n");
201 fprintf(log_file, " (i = in_stack, n = nest_stack, p = param_stack, b = buf_stack, s = save_stack)\n");
204 fprintf(log_file, " %lld inputs open max out of %d\n", high_in_open, max_in_open);
206 if (show_line_break_stats && first_pass_count > 0)
208 int first_count, second_count, third_count;
210 fprintf(log_file, "\nSuccess at breaking %d paragraph%s:", first_pass_count, (first_pass_count == 1) ? "" : "s");
213 fprintf(log_file, "\n %d single line `paragraph%s'", single_line, (single_line == 1) ? "" : "s");
215 first_count = first_pass_count - single_line - second_pass_count;
220 second_count = second_pass_count - final_pass_count;
221 third_count = final_pass_count - paragraph_failed;
223 if (first_pass_count > 0)
224 fprintf(log_file, "\n %d first pass (\\pretolerance = %lld)", first_pass_count, pretolerance);
226 if (second_pass_count > 0)
227 fprintf(log_file, "\n %d second pass (\\tolerance = %lld)", second_pass_count, tolerance);
229 if (final_pass_count > 0 || emergency_stretch > 0)
230 fprintf(log_file, "\n %d third pass (\\emergencystretch = %lgpt)",
231 final_pass_count, (double) emergency_stretch / 65536.0);
233 if (paragraph_failed > 0)
234 fprintf(log_file, "\n %d failed", paragraph_failed);
236 putc('\n', log_file);
238 if (overfull_hbox > 0)
239 fprintf(log_file, "\n %d overfull \\hbox%s", overfull_hbox, (overfull_hbox > 1) ? "es" : "");
241 if (underfull_hbox > 0)
242 fprintf(log_file, "\n %d underfull \\hbox%s", underfull_hbox, (underfull_hbox > 1) ? "es" : "");
244 if (overfull_vbox > 0)
245 fprintf(log_file, "\n %d overfull \\vbox%s", overfull_vbox, (overfull_vbox > 1) ? "es" : "");
247 if (underfull_vbox > 0)
248 fprintf(log_file, "\n %d underfull \\vbox%s", underfull_vbox, (underfull_vbox > 1) ? "es" : "");
250 if (overfull_hbox || underfull_hbox || overfull_vbox || underfull_vbox)
251 putc('\n', log_file);
256 switch (shipout_flag)
274 if (total_pages == 0)
275 print_nl("No pages of output.");
280 last_bop = dvi_offset + dvi_ptr - 5;
282 dvi_four(473628672L);
287 dvi_out(max_push / 256);
288 dvi_out(max_push % 256);
290 if (total_pages >= 65536)
292 sprintf(log_line, "\nWARNING: page count (dvi_t) in DVI file will be %lld not %lld\n",
293 (total_pages % 65536), total_pages);
296 fputs(log_line, log_file);
298 show_line(log_line, 1);
301 dvi_out((total_pages / 256) % 256);
302 dvi_out(total_pages % 256);
304 if (show_fonts_used && log_opened)
309 if (font_used[font_ptr])
310 dvi_font_def(font_ptr);
318 k = 4 + ((dvi_buf_size - dvi_ptr) % 4);
327 printf("\ndvi_write %lld", dvi_gone);
329 if (dvi_limit == half_buf)
330 write_dvi(half_buf, dvi_buf_size - 1);
333 write_dvi(0, dvi_ptr - 1);
335 print_nl("Output written on ");
337 if (full_file_name_flag && dvi_file_name != NULL)
338 prints(dvi_file_name);
340 slow_print(output_file_name);
343 print_int(total_pages);
346 if (total_pages != 1)
350 print_int(dvi_offset + dvi_ptr);
362 selector = selector - 2;
364 if (selector == term_only)
366 print_nl("Transcript written on ");
368 if (full_file_name_flag && log_file_name != NULL)
369 prints(log_file_name);
371 slow_print(log_name);
379 if ((edit_name_start != 0) && (interaction > 0))
380 call_edit(str_pool, edit_name_start, edit_name_length, edit_line);
384 void debug_help (void)
390 print_nl(" debug # (-1 to exit):");
396 read(stdin, m); // ???
413 print_int(mem[n].hh.lh);
417 print_int(mem[n].hh.rh);
426 print_scaled(font_info[n].sc);
428 print_int(font_info[n].b0);
430 print_int(font_info[n].b1);
432 print_int(font_info[n].b2);
434 print_int(font_info[n].b3);
436 print_word(font_info[n]);
441 print_word(save_stack[n]);
451 #ifdef ALLOCATESTRING
452 if (pool_ptr + 32000 > current_pool_size)
453 str_pool = realloc_str_pool (increment_pool_size);
455 #ifdef ALLOCATESTRING
456 depth_threshold = current_pool_size - pool_ptr - 10;
458 depth_threshold = pool_size - pool_ptr - 10;
465 show_token_list(n, 0, 1000);
489 for (k = 0; k <= n; k++)
496 font_in_short_display = 0;
502 panicking = !panicking;