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
22 /* end of the old tex8.c */
24 void give_err_help (void)
29 boolean open_fmt_file (void)
35 if (buffer[loc] == '&' || buffer[loc] == '+')
41 while (buffer[j] != ' ')
44 pack_buffered_name(0, loc, j - 1);
46 if (w_open_in(fmt_file))
51 sprintf(log_line, "%s;%s\n", "Sorry, I can't find that format",
52 " will try the default.");
53 show_line(log_line, 1);
59 name_of_file[name_length + 1] = '\0';
60 sprintf(s, "%s (%s);%s\n", "Sorry, I can't find that format",
61 name_of_file + 1, " will try the default.");
62 name_of_file[name_length + 1] = ' ';
64 sprintf(s, "(Perhaps your %s environment variable is not set correctly)\n",
67 show_line(log_line, 1);
75 pack_buffered_name(format_default_length - 4, 1, 0);
77 if (!w_open_in(fmt_file))
81 sprintf(log_line, "%s!\n", "I can't find the default format file");
82 show_line(log_line, 1);
88 name_of_file[name_length + 1] = '\0';
89 sprintf(s, "%s (%s)!\n", "I can't find the default format file", name_of_file + 1);
90 name_of_file[name_length + 1] = ' ';
92 sprintf(s, "(Perhaps your %s environment variable is not set correctly)\n", "TEXFORMATS");
94 show_line(log_line, 1);
105 /**************************************************************************/
106 void print_char_string (unsigned char *s)
111 void show_font_info (void); // now in local.c
112 extern int closed_already; // make sure we don't try this more than once
114 void close_files_and_terminate (void)
118 if (closed_already++)
120 puts("close_files_and_terminated already ");
121 return; // sanity check
125 puts("\nclose_files_and_terminate ");
127 for (k = 0; k <= 15; k++)
130 (void) a_close(write_file[k]);
134 if (tracing_stats > 0 || verbose_flag != 0)
137 fprintf(log_file, "%c\n", ' ');
138 fprintf(log_file, "\n");
139 fprintf(log_file, "%s%s\n", "Here is how much of TeX's memory", " you used:");
140 fprintf(log_file, "%c%ld%s", ' ', str_ptr - init_str_ptr, " string");
142 if (str_ptr != init_str_ptr + 1)
145 #ifdef ALLOCATESTRING
147 fprintf(log_file, "%s%ld\n", " out of ", current_max_strings - init_str_ptr);
150 fprintf(log_file, "%s%ld\n", " out of ", max_strings - init_str_ptr);
152 #ifdef ALLOCATESTRING
154 fprintf(log_file, "%c%ld%s%ld\n", ' ', pool_ptr - init_pool_ptr, " string characters out of ", current_pool_size - init_pool_ptr);
157 fprintf(log_file, "%c%ld%s%ld\n", ' ', pool_ptr - init_pool_ptr, " string characters out of ", pool_size - init_pool_ptr);
161 fprintf(log_file, "%c%ld%s%ld\n", ' ', (long)lo_mem_max - mem_min + mem_end - hi_mem_min + 2, " words of memory out of ", current_mem_size);
164 fprintf(log_file, "%c%ld%s%ld\n", ' ', (long)lo_mem_max - mem_min + mem_end - hi_mem_min + 2, " words of memory out of ", mem_end + 1 - mem_min);
166 fprintf(log_file, "%c%ld%s%ld\n", ' ', cs_count, " multiletter control sequences out of ", (hash_size + hash_extra));
167 fprintf(log_file, "%c%ld%s%ld%s", ' ', (long)fmem_ptr, " words of font info for ", (long)font_ptr - font_base, " font");
174 fprintf(log_file, "%s%ld%s%ld\n", ", out of ", current_font_mem_size, " for ", font_max - font_base);
177 fprintf(log_file, "%s%ld%s%ld\n", ", out of ", font_mem_size, " for ", font_max - font_base);
179 fprintf(log_file, "%c%ld%s", ' ', hyph_count, " hyphenation exception");
184 fprintf(log_file, "%s%ld\n", " out of ", hyphen_prime);
185 fprintf(log_file, " ");
186 fprintf(log_file, "%ld%s", max_in_stack, "i,");
187 fprintf(log_file, "%ld%s", max_nest_stack, "n,");
188 fprintf(log_file, "%ld%s", max_param_stack, "p,");
189 fprintf(log_file, "%ld%s", max_buf_stack + 1, "b,");
190 fprintf(log_file, "%ld%s", max_save_stack + 6, "s");
191 fprintf(log_file, " stack positions out of ");
193 #ifdef ALLOCATESAVESTACK
195 fprintf(log_file, "%ld%s", current_stack_size, "i,");
198 fprintf(log_file, "%ld%s", stack_size, "i,");
200 #ifdef ALLOCATENESTSTACK
202 fprintf(log_file, "%ld%s", current_nest_size, "n,");
205 fprintf(log_file, "%ld%s", nest_size, "n,");
207 #ifdef ALLOCATEPARAMSTACK
209 fprintf(log_file, "%ld%s", current_param_size, "p,");
212 fprintf(log_file, "%ld%s", param_size, "p,");
214 #ifdef ALLOCATEBUFFER
216 fprintf(log_file, "%ld%s", current_buf_size, "b,");
219 fprintf(log_file, "%ld%s", buf_size, "b,");
221 #ifdef ALLOCATESAVESTACK
223 fprintf(log_file, "%ld%s", current_save_size, "s");
226 fprintf(log_file, "%ld%s", save_size, "s");
228 fprintf(log_file, "\n");
231 fprintf(log_file, " (i = in_stack, n = nest_stack, p = param_stack, b = buf_stack, s = save_stack)\n");
234 fprintf(log_file, " %d inputs open max out of %d\n", high_in_open, max_in_open);
236 if (show_line_break_stats && first_pass_count > 0)
238 int first_count, second_count, third_count;
240 fprintf(log_file, "\nSuccess at breaking %d paragraph%s:", first_pass_count, (first_pass_count == 1) ? "" : "s");
243 fprintf(log_file, "\n %d single line `paragraph%s'", single_line, (single_line == 1) ? "" : "s");
245 first_count = first_pass_count - single_line - second_pass_count;
250 second_count = second_pass_count - final_pass_count;
251 third_count = final_pass_count - paragraph_failed;
253 if (first_pass_count > 0)
254 fprintf(log_file, "\n %d first pass (\\pretolerance = %d)", first_pass_count, pretolerance);
256 if (second_pass_count > 0)
257 fprintf(log_file, "\n %d second pass (\\tolerance = %d)", second_pass_count, tolerance);
259 if (final_pass_count > 0 || emergency_stretch > 0)
261 fprintf(log_file, "\n %d third pass (\\emergencystretch = %lgpt)", final_pass_count, (double) emergency_stretch / 65536.0);
264 if (paragraph_failed > 0)
265 fprintf(log_file, "\n %d failed", paragraph_failed);
267 putc('\n', log_file);
269 if (overfull_hbox > 0)
270 fprintf(log_file, "\n %d overfull \\hbox%s", overfull_hbox, (overfull_hbox > 1) ? "es" : "");
272 if (underfull_hbox > 0)
273 fprintf(log_file, "\n %d underfull \\hbox%s", underfull_hbox, (underfull_hbox > 1) ? "es" : "");
275 if (overfull_vbox > 0)
276 fprintf(log_file, "\n %d overfull \\vbox%s", overfull_vbox, (overfull_vbox > 1) ? "es" : "");
278 if (underfull_vbox > 0)
279 fprintf(log_file, "\n %d underfull \\vbox%s", underfull_vbox, (underfull_vbox > 1) ? "es" : "");
281 if (overfull_hbox || underfull_hbox || overfull_vbox || underfull_vbox)
282 putc('\n', log_file);
287 switch (shipout_flag)
291 if (total_pages == 0)
293 print_nl("No pages of output.");
297 HPDF_SaveToFile(yandy_pdf, pdf_file_name);
299 print_nl("Output written on ");
301 if (full_file_name_flag && pdf_file_name != NULL)
302 print_char_string((unsigned char *) pdf_file_name);
304 slow_print(output_file_name);
307 print_int(total_pages);
308 print_string(" page");
310 if (total_pages != 1)
316 HPDF_Free(yandy_pdf);
317 font_name_hash_free(gentbl);
336 if (total_pages == 0)
337 print_nl("No pages of output.");
342 last_bop = dvi_offset + dvi_ptr - 5;
344 dvi_four(473628672L);
349 dvi_out(max_push / 256);
350 dvi_out(max_push % 256);
352 if (total_pages >= 65536) // 99/Oct/10 dvi_t 16 bit problem
354 sprintf(log_line, "\nWARNING: page count (dvi_t) in DVI file will be %ld not %ld\n",
355 (total_pages % 65536), total_pages);
358 (void) fputs (log_line, log_file);
360 show_line(log_line, 1);
363 dvi_out((total_pages / 256) % 256);
364 dvi_out(total_pages % 256);
366 if (show_fonts_used && log_opened) /* 97/Dec/24 */
367 show_font_info(); // now in local.c
371 if (font_used[font_ptr])
372 dvi_font_def(font_ptr);
380 k = 4 + ((dvi_buf_size - dvi_ptr) % 4);
388 if (trace_flag) /* 93/Dec/28 - bkph */
390 sprintf(log_line, "\ndviwrite %d", dvi_gone);
391 show_line(log_line, 0);
394 if (dvi_limit == half_buf)
395 write_dvi(half_buf, dvi_buf_size - 1);
398 write_dvi(0, dvi_ptr - 1);
400 print_nl("Output written on ");
402 if (full_file_name_flag && dvi_file_name != NULL)
403 print_char_string((unsigned char *) dvi_file_name);
405 slow_print(output_file_name);
408 print_int(total_pages);
409 print_string(" page");
411 if (total_pages != 1)
415 print_int(dvi_offset + dvi_ptr);
416 print_string(" bytes).");
425 putc('\n', log_file);
427 selector = selector - 2;
429 if (selector == term_only)
431 print_nl("Transcript written on ");
433 if (full_file_name_flag && log_file_name != NULL)
434 print_char_string((unsigned char *) log_file_name);
436 slow_print(texmf_log_name);
444 if ((edit_name_start != 0) && (interaction > 0))
445 call_edit(str_pool, edit_name_start, edit_name_length, edit_line);
449 void debug_help (void)
455 print_nl(" debug # (-1 to exit):");
461 read(stdin, m); // ???
478 print_int(mem[n].hh.lh);
482 print_int(mem[n].hh.rh);
491 print_scaled(font_info[n].sc);
493 print_int(font_info[n].b0);
495 print_int(font_info[n].b1);
497 print_int(font_info[n].b2);
499 print_int(font_info[n].b3);
501 print_word(font_info[n]);
506 print_word(save_stack[n]);
516 #ifdef ALLOCATESTRING
517 if (pool_ptr + 32000 > current_pool_size)
518 str_pool = realloc_str_pool (increment_pool_size);
520 #ifdef ALLOCATESTRING
521 depth_threshold = current_pool_size - pool_ptr - 10;
523 depth_threshold = pool_size - pool_ptr - 10;
530 show_token_list(n, 0, 1000);
554 for (k = 0; k <= n; k++)
561 font_in_short_display = 0;
567 panicking = !panicking;