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 inline void update_terminal(void)
29 inline void check_full_save_stack(void)
31 if (save_ptr > max_save_stack)
33 max_save_stack = save_ptr;
35 #ifdef ALLOCATESAVESTACK
36 if (max_save_stack > current_save_size - 6)
37 save_stack = realloc_save_stack(increment_save_size);
39 if (max_save_stack > current_save_size - 6)
41 overflow("save size", current_save_size);
45 if (max_save_stack > save_size - 6)
47 overflow("save size", save_size);
53 inline void write_dvi(size_t a, size_t b)
55 if (fwrite((char *) &dvi_buf[a], sizeof(dvi_buf[a]),
56 ((b) - (a) + 1), dvi_file) != ((b) - (a) + 1))
57 FATAL_PERROR ("\n! dvi file");
59 inline void prompt_input(const char * s)
64 inline void set_cur_lang(void)
68 else if (language > 255)
73 inline void free_avail_(halfword p)
82 inline void append_char (ASCII_code c)
84 str_pool[pool_ptr] = c;
88 inline void str_room(int val)
91 if (pool_ptr + val > current_pool_size)
92 str_pool = realloc_str_pool(increment_pool_size);
94 if (pool_ptr + val > current_pool_size)
95 overflow("pool size", current_pool_size - init_pool_ptr);
97 if (pool_ptr + val > pool_size)
98 overflow("pool size", pool_size - init_pool_ptr);
102 inline void flush_string (void)
105 pool_ptr = str_start[str_ptr];
108 inline void append_lc_hex (ASCII_code c)
111 append_char(c + '0');
113 append_char(c - 10 + 'a');
116 inline void print_err (const char * s)
118 if (interaction == error_stop_mode);
124 inline void tex_help (unsigned int n, ...)
133 va_start(help_arg, n);
135 for (i = n - 1; i > -1; --i)
136 help_line[i] = va_arg(help_arg, char *);
141 inline void succumb (void)
143 if (interaction == error_stop_mode)
144 interaction = scroll_mode;
156 history = error_stop_mode;
160 inline void tail_append_ (pointer val)
166 inline void push_input(void)
168 if (input_ptr > max_in_stack)
170 max_in_stack = input_ptr;
172 #ifdef ALLOCATEINPUTSTACK
173 if (input_ptr == current_stack_size)
174 input_stack = realloc_input_stack(increment_stack_size);
176 if (input_ptr == current_stack_size)
178 overflow("input stack size", current_stack_size);
182 if (input_ptr == stack_size)
184 overflow("input stack size", stack_size);
190 input_stack[input_ptr] = cur_input;
194 inline void pop_input(void)
197 cur_input = input_stack[input_ptr];
200 inline void ensure_dvi_open(void)
202 if (output_file_name == 0)
207 pack_job_name(".dvi");
209 while (!b_open_out(dvi_file))
211 prompt_file_name("file name for output", ".dvi");
214 output_file_name = b_make_name_string(dvi_file);
218 inline void dvi_out_(ASCII_code op)
220 dvi_buf[dvi_ptr] = op;
223 if (dvi_ptr == dvi_limit)
227 inline void synch_h(void)
231 movement(cur_h - dvi_h, right1);
236 inline void synch_v(void)
240 movement(cur_v - dvi_v, down1);