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
20 #include "yandytex.h"
\r
23 void do_nothing(void)
\r
28 void update_terminal(void)
\r
33 void append_char (ASCII_code c)
\r
35 str_pool[pool_ptr] = c;
\r
39 void str_room(int val)
\r
41 #ifdef ALLOCATESTRING
\r
42 if (pool_ptr + val > current_pool_size)
\r
43 str_pool = realloc_str_pool(increment_pool_size);
\r
45 if (pool_ptr + val > current_pool_size)
\r
46 overflow("pool size", current_pool_size - init_pool_ptr);
\r
48 if (pool_ptr + val > pool_size)
\r
49 overflow("pool size", pool_size - init_pool_ptr);
\r
53 void flush_string (void)
\r
56 pool_ptr = str_start[str_ptr];
\r
59 void append_lc_hex (ASCII_code c)
\r
62 append_char(c + '0');
\r
64 append_char(c - 10 + 'a');
\r
68 void print_err (const char * s)
\r
70 if (interaction == error_stop_mode)
\r
77 void prompt_input(const char * s)
\r
83 void tex_help (unsigned int n, ...)
\r
92 va_start(help_arg, n);
\r
94 for (i = n - 1; i > -1; --i)
\r
95 help_line[i] = va_arg(help_arg, char *);
\r
100 void succumb (void)
\r
102 if (interaction == error_stop_mode)
\r
103 interaction = scroll_mode;
\r
109 if (interaction > 0)
\r
113 history = error_stop_mode;
\r
117 void free_avail_(halfword p)
\r
126 void node_list_display (integer p)
\r
133 void tail_append_ (pointer val)
\r
139 void check_full_save_stack(void)
\r
141 if (save_ptr > max_save_stack)
\r
143 max_save_stack = save_ptr;
\r
145 #ifdef ALLOCATESAVESTACK
\r
146 if (max_save_stack > current_save_size - 6)
\r
147 save_stack = realloc_save_stack(increment_save_size);
\r
149 if (max_save_stack > current_save_size - 6)
\r
151 overflow("save size", current_save_size);
\r
155 if (max_save_stack > save_size - 6)
\r
157 overflow("save size", save_size);
\r
164 void push_input(void)
\r
166 if (input_ptr > max_in_stack)
\r
168 max_in_stack = input_ptr;
\r
170 #ifdef ALLOCATEINPUTSTACK
\r
171 if (input_ptr == current_stack_size)
\r
172 input_stack = realloc_input_stack(increment_stack_size);
\r
174 if (input_ptr == current_stack_size)
\r
176 overflow("input stack size", current_stack_size);
\r
180 if (input_ptr == stack_size)
\r
182 overflow("input stack size", stack_size);
\r
188 input_stack[input_ptr] = cur_input;
\r
192 void pop_input(void)
\r
195 cur_input = input_stack[input_ptr];
\r
198 void ensure_dvi_open (void)
\r
200 if (output_file_name == 0)
\r
205 pack_job_name(".dvi");
\r
207 while (!b_open_out(dvi_file))
\r
208 prompt_file_name("file name for output", ".dvi");
\r
210 output_file_name = b_make_name_string(dvi_file);
\r
216 fbyte = getc(tfm_file);
\r
219 void write_dvi(size_t a, size_t b)
\r
221 if (fwrite((char *)&dvi_buf[a], sizeof(dvi_buf[a]),
\r
222 (b - a + 1), dvi_file) != (b - a + 1))
\r
223 FATAL_PERROR("\n! dvi file");
\r
226 void dvi_out_(ASCII_code op)
\r
228 dvi_buf[dvi_ptr] = op;
\r
231 if (dvi_ptr == dvi_limit)
\r
235 void synch_h (void)
\r
237 if (cur_h != dvi_h)
\r
239 movement(cur_h - dvi_h, right1);
\r
244 void synch_v (void)
\r
246 if (cur_v != dvi_v)
\r
248 movement(cur_v - dvi_v, down1);
\r
253 void set_cur_lang (void)
\r
257 else if (language > 255)
\r
260 cur_lang = language;
\r
263 void print_plus (int i, const char * s)
\r
265 if (page_so_far[i] != 0)
\r
268 print_scaled(page_so_far[i]);
\r