1 /* Copyright 2014 Clerk Ma
\r
3 This program is free software; you can redistribute it and/or modify
\r
4 it under the terms of the GNU General Public License as published by
\r
5 the Free Software Foundation; either version 2 of the License, or
\r
6 (at your option) any later version.
\r
8 This program is distributed in the hope that it will be useful, but
\r
9 WITHOUT ANY WARRANTY; without even the implied warranty of
\r
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
11 General Public License for more details.
\r
13 You should have received a copy of the GNU General Public License
\r
14 along with this program; if not, write to the Free Software
\r
15 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
\r
18 #define EXTERN extern
\r
21 #include "yandytex.h"
\r
24 void give_err_help (void)
\r
26 token_show(err_help);
\r
29 boolean open_fmt_file (void)
\r
35 if (buffer[loc] == '&' || buffer[loc] == '+')
\r
41 while (buffer[j] != ' ')
\r
44 pack_buffered_name(0, loc, j - 1);
\r
46 if (w_open_in(fmt_file))
\r
50 printf("%s;%s\n", "Sorry, I can't find that format", " will try the default.");
\r
53 name_of_file[name_length + 1] = '\0';
\r
54 printf("%s (%s);%s\n", "Sorry, I can't find that format",
\r
55 name_of_file + 1, " will try the default.");
\r
56 name_of_file[name_length + 1] = ' ';
\r
57 printf("(Perhaps your %s environment variable is not set correctly)\n",
\r
64 pack_buffered_name(format_default_length - 4, 1, 0);
\r
66 if (!w_open_in(fmt_file))
\r
69 printf("%s!\n", "I can't find the default format file");
\r
72 name_of_file[name_length + 1] = '\0';
\r
73 printf("%s (%s)!\n", "I can't find the default format file", name_of_file + 1);
\r
74 name_of_file[name_length + 1] = ' ';
\r
75 printf("(Perhaps your %s environment variable is not set correctly)\n", "TEXFORMATS");
\r
87 void close_files_and_terminate (void)
\r
92 puts("\nclose_files_and_terminate() ");
\r
94 for (k = 0; k <= 15; k++)
\r
96 a_close(write_file[k]);
\r
99 if (tracing_stats > 0 || verbose_flag != 0)
\r
102 fprintf(log_file, "%c\n", ' ');
\r
103 fprintf(log_file, "\n");
\r
104 fprintf(log_file, "%s%s\n", "Here is how much of TeX's memory", " you used:");
\r
105 fprintf(log_file, "%c%lld%s", ' ', (integer)(str_ptr - init_str_ptr), " string");
\r
107 if (str_ptr != init_str_ptr + 1)
\r
108 putc('s', log_file);
\r
110 #ifdef ALLOCATESTRING
\r
112 fprintf(log_file, "%s%d\n", " out of ", (int)(current_max_strings - init_str_ptr));
\r
115 fprintf(log_file, "%s%d\n", " out of ", (int)(max_strings - init_str_ptr));
\r
117 #ifdef ALLOCATESTRING
\r
119 fprintf(log_file, "%c%lld%s%lld\n", ' ', (integer)(pool_ptr - init_pool_ptr), " string characters out of ", current_pool_size - init_pool_ptr);
\r
122 fprintf(log_file, "%c%lld%s%lld\n", ' ', (integer)(pool_ptr - init_pool_ptr), " string characters out of ", pool_size - init_pool_ptr);
\r
124 #ifdef ALLOCATEMAIN
\r
126 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);
\r
129 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);
\r
131 fprintf(log_file, "%c%lld%s%d\n", ' ', (cs_count), " multiletter control sequences out of ", (hash_size + hash_extra));
\r
132 fprintf(log_file, "%c%lld%s%lld%s", ' ', (fmem_ptr), " words of font info for ", (font_ptr - font_base), " font");
\r
137 #ifdef ALLOCATEFONT
\r
139 fprintf(log_file, "%s%d%s%d\n", ", out of ", current_font_mem_size, " for ", font_max - font_base);
\r
142 fprintf(log_file, "%s%lu%s%d\n", ", out of ", font_mem_size, " for ", font_max - font_base);
\r
144 fprintf(log_file, "%c%lld%s", ' ', hyph_count, " hyphenation exception");
\r
146 if (hyph_count != 1)
\r
149 fprintf(log_file, "%s%lld\n", " out of ", hyphen_prime);
\r
150 fprintf(log_file, " ");
\r
151 fprintf(log_file, "%d%s", (int) max_in_stack, "i,");
\r
152 fprintf(log_file, "%d%s", (int) max_nest_stack, "n,");
\r
153 fprintf(log_file, "%d%s", (int) max_param_stack, "p,");
\r
154 fprintf(log_file, "%d%s", (int) max_buf_stack + 1, "b,");
\r
155 fprintf(log_file, "%d%s", (int) max_save_stack + 6, "s");
\r
156 fprintf(log_file, " stack positions out of ");
\r
158 #ifdef ALLOCATESAVESTACK
\r
160 fprintf(log_file, "%d%s", current_stack_size, "i,");
\r
163 fprintf(log_file, "%d%s", stack_size, "i,");
\r
165 #ifdef ALLOCATENESTSTACK
\r
167 fprintf(log_file, "%d%s", current_nest_size, "n,");
\r
170 fprintf(log_file, "%d%s", nest_size, "n,");
\r
172 #ifdef ALLOCATEPARAMSTACK
\r
174 fprintf(log_file, "%d%s", current_param_size, "p,");
\r
177 fprintf(log_file, "%d%s", param_size, "p,");
\r
179 #ifdef ALLOCATEBUFFER
\r
181 fprintf(log_file, "%d%s", current_buf_size, "b,");
\r
184 fprintf(log_file, "%ld%s", buf_size, "b,");
\r
186 #ifdef ALLOCATESAVESTACK
\r
188 fprintf(log_file, "%d%s", current_save_size, "s");
\r
191 fprintf(log_file, "%d%s", save_size, "s");
\r
193 fprintf(log_file, "\n");
\r
196 fprintf(log_file, " (i = in_stack, n = nest_stack, p = param_stack, b = buf_stack, s = save_stack)\n");
\r
199 fprintf(log_file, " %lld inputs open max out of %d\n", high_in_open, max_in_open);
\r
201 if (show_line_break_stats && first_pass_count > 0)
\r
203 int first_count, second_count, third_count;
\r
205 fprintf(log_file, "\nSuccess at breaking %d paragraph%s:", first_pass_count, (first_pass_count == 1) ? "" : "s");
\r
207 if (single_line > 0)
\r
208 fprintf(log_file, "\n %d single line `paragraph%s'", single_line, (single_line == 1) ? "" : "s");
\r
210 first_count = first_pass_count - single_line - second_pass_count;
\r
212 if (first_count < 0)
\r
215 second_count = second_pass_count - final_pass_count;
\r
216 third_count = final_pass_count - paragraph_failed;
\r
218 if (first_pass_count > 0)
\r
219 fprintf(log_file, "\n %d first pass (\\pretolerance = %lld)", first_pass_count, pretolerance);
\r
221 if (second_pass_count > 0)
\r
222 fprintf(log_file, "\n %d second pass (\\tolerance = %lld)", second_pass_count, tolerance);
\r
224 if (final_pass_count > 0 || emergency_stretch > 0)
\r
225 fprintf(log_file, "\n %d third pass (\\emergencystretch = %lgpt)",
\r
226 final_pass_count, (double) emergency_stretch / 65536.0);
\r
228 if (paragraph_failed > 0)
\r
229 fprintf(log_file, "\n %d failed", paragraph_failed);
\r
231 putc('\n', log_file);
\r
233 if (overfull_hbox > 0)
\r
234 fprintf(log_file, "\n %d overfull \\hbox%s", overfull_hbox, (overfull_hbox > 1) ? "es" : "");
\r
236 if (underfull_hbox > 0)
\r
237 fprintf(log_file, "\n %d underfull \\hbox%s", underfull_hbox, (underfull_hbox > 1) ? "es" : "");
\r
239 if (overfull_vbox > 0)
\r
240 fprintf(log_file, "\n %d overfull \\vbox%s", overfull_vbox, (overfull_vbox > 1) ? "es" : "");
\r
242 if (underfull_vbox > 0)
\r
243 fprintf(log_file, "\n %d underfull \\vbox%s", underfull_vbox, (underfull_vbox > 1) ? "es" : "");
\r
245 if (overfull_hbox || underfull_hbox || overfull_vbox || underfull_vbox)
\r
246 putc('\n', log_file);
\r
252 spc_exec_at_end_document();
\r
253 pdf_close_document();
\r
254 pdf_close_device();
\r
256 pdf_close_fontmaps();
\r
258 if (total_pages == 0)
\r
259 print_nl("No pages of output.");
\r
262 if (total_pages >= 65536)
\r
264 sprintf(log_line, "\nWARNING: page count (dvi_t) in DVI file will be %lld not %lld\n",
\r
265 (total_pages % 65536), total_pages);
\r
268 fputs(log_line, log_file);
\r
270 show_line(log_line, 1);
\r
273 print_nl("Output written on ");
\r
275 if (full_file_name_flag && pdf_file_name != NULL)
\r
276 prints(pdf_file_name);
\r
278 slow_print(output_file_name);
\r
281 print_int(total_pages);
\r
284 if (total_pages != 1)
\r
288 print_int(pdf_output_stats());
\r
289 prints(" bytes).");
\r
295 switch (shipout_flag)
\r
313 if (total_pages == 0)
\r
314 print_nl("No pages of output.");
\r
318 dvi_four(last_bop);
\r
319 last_bop = dvi_offset + dvi_ptr - 5;
\r
320 dvi_four(25400000L);
\r
321 dvi_four(473628672L);
\r
326 dvi_out(max_push / 256);
\r
327 dvi_out(max_push % 256);
\r
329 if (total_pages >= 65536)
\r
331 sprintf(log_line, "\nWARNING: page count (dvi_t) in DVI file will be %lld not %lld\n",
\r
332 (total_pages % 65536), total_pages);
\r
335 fputs(log_line, log_file);
\r
337 show_line(log_line, 1);
\r
340 dvi_out((total_pages / 256) % 256);
\r
341 dvi_out(total_pages % 256);
\r
343 if (show_fonts_used && log_opened)
\r
346 while (font_ptr > 0)
\r
348 if (font_used[font_ptr])
\r
349 dvi_font_def(font_ptr);
\r
354 dvi_out(post_post);
\r
355 dvi_four(last_bop);
\r
357 k = 4 + ((dvi_buf_size - dvi_ptr) % 4);
\r
366 printf("\ndvi_write %lld", dvi_gone);
\r
368 if (dvi_limit == half_buf)
\r
369 write_dvi(half_buf, dvi_buf_size - 1);
\r
372 write_dvi(0, dvi_ptr - 1);
\r
374 print_nl("Output written on ");
\r
376 if (full_file_name_flag && dvi_file_name != NULL)
\r
377 prints(dvi_file_name);
\r
379 slow_print(output_file_name);
\r
382 print_int(total_pages);
\r
385 if (total_pages != 1)
\r
389 print_int(dvi_offset + dvi_ptr);
\r
390 prints(" bytes).");
\r
401 selector = selector - 2;
\r
403 if (selector == term_only)
\r
405 print_nl("Transcript written on ");
\r
407 if (full_file_name_flag && log_file_name != NULL)
\r
408 prints(log_file_name);
\r
410 slow_print(log_name);
\r
418 if ((edit_name_start != 0) && (interaction > 0))
\r
419 call_edit(str_pool, edit_name_start, edit_name_length, edit_line);
\r
423 void debug_help (void)
\r
425 integer k, l, m, n;
\r
429 print_nl(" debug # (-1 to exit):");
\r
435 read(stdin, m); // ???
\r
448 print_word(mem[n]);
\r
452 print_int(mem[n].hh.lh);
\r
456 print_int(mem[n].hh.rh);
\r
460 print_word(eqtb[n]);
\r
464 #ifdef SHORTFONTINFO
\r
465 print_scaled(font_info[n].sc);
\r
467 print_int(font_info[n].b0);
\r
469 print_int(font_info[n].b1);
\r
471 print_int(font_info[n].b2);
\r
473 print_int(font_info[n].b3);
\r
475 print_word(font_info[n]);
\r
480 print_word(save_stack[n]);
\r
489 breadth_max = 10000;
\r
490 #ifdef ALLOCATESTRING
\r
491 if (pool_ptr + 32000 > current_pool_size)
\r
492 str_pool = realloc_str_pool (increment_pool_size);
\r
494 #ifdef ALLOCATESTRING
\r
495 depth_threshold = current_pool_size - pool_ptr - 10;
\r
497 depth_threshold = pool_size - pool_ptr - 10;
\r
504 show_token_list(n, 0, 1000);
\r
522 print_cmd_chr(n, l);
\r
528 for (k = 0; k <= n; k++)
\r
535 font_in_short_display = 0;
\r
541 panicking = !panicking;
\r