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 do_nothing(void)
25 printf("DO_NOTHING.\n");
28 inline void update_terminal(void)
35 inline void check_full_save_stack(void)
37 if (save_ptr > max_save_stack)
39 max_save_stack = save_ptr;
41 #ifdef ALLOCATESAVESTACK
42 if (max_save_stack > current_save_size - 6)
43 save_stack = realloc_save_stack(increment_save_size);
45 if (max_save_stack > current_save_size - 6)
47 overflow("save size", current_save_size);
51 if (max_save_stack > save_size - 6)
53 overflow("save size", save_size);
59 inline void write_dvi(size_t a, size_t b)
61 if (fwrite((char *) &dvi_buf[a], sizeof(dvi_buf[a]),
62 ((b) - (a) + 1), dvi_file) != ((b) - (a) + 1))
63 FATAL_PERROR ("\n! dvi file");
65 inline void prompt_input(const char * s)
70 inline void set_cur_lang(void)
74 else if (language > 255)
79 inline void free_avail_(halfword p)
88 inline void append_char (ASCII_code c)
90 str_pool[pool_ptr] = c;
94 inline void str_room(int val)
97 if (pool_ptr + val > current_pool_size)
98 str_pool = realloc_str_pool(increment_pool_size);
100 if (pool_ptr + val > current_pool_size)
101 overflow("pool size", current_pool_size - init_pool_ptr);
103 if (pool_ptr + val > pool_size)
104 overflow("pool size", pool_size - init_pool_ptr);
108 inline void flush_string (void)
111 pool_ptr = str_start[str_ptr];
114 inline void append_lc_hex (ASCII_code c)
117 append_char(c + '0');
119 append_char(c - 10 + 'a');
122 inline void print_err (const char * s)
124 if (interaction == error_stop_mode)
131 inline void tex_help (unsigned int n, ...)
140 va_start(help_arg, n);
142 for (i = n - 1; i > -1; --i)
143 help_line[i] = va_arg(help_arg, char *);
148 inline void succumb (void)
150 if (interaction == error_stop_mode)
151 interaction = scroll_mode;
163 history = error_stop_mode;
167 inline void tail_append_ (pointer val)
173 inline void push_input(void)
175 if (input_ptr > max_in_stack)
177 max_in_stack = input_ptr;
179 #ifdef ALLOCATEINPUTSTACK
180 if (input_ptr == current_stack_size)
181 input_stack = realloc_input_stack(increment_stack_size);
183 if (input_ptr == current_stack_size)
185 overflow("input stack size", current_stack_size);
189 if (input_ptr == stack_size)
191 overflow("input stack size", stack_size);
197 input_stack[input_ptr] = cur_input;
201 inline void pop_input(void)
204 cur_input = input_stack[input_ptr];
207 inline void ensure_dvi_open(void)
209 if (output_file_name == 0)
214 pack_job_name(".dvi");
216 while (!b_open_out(dvi_file))
218 prompt_file_name("file name for output", ".dvi");
221 output_file_name = b_make_name_string(dvi_file);
225 inline void dvi_out_(ASCII_code op)
227 dvi_buf[dvi_ptr] = op;
230 if (dvi_ptr == dvi_limit)
234 inline void synch_h(void)
238 movement(cur_h - dvi_h, right1);
243 inline void synch_v(void)
247 movement(cur_v - dvi_v, down1);