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 push_input(void)
24 if (input_ptr > max_in_stack)
26 max_in_stack = input_ptr;
28 #ifdef ALLOCATEINPUTSTACK
29 if (input_ptr == current_stack_size)
30 input_stack = realloc_input_stack(increment_stack_size);
32 if (input_ptr == current_stack_size)
34 overflow("input stack size", current_stack_size);
38 if (input_ptr == stack_size)
40 overflow("input stack size", stack_size);
46 input_stack[input_ptr] = cur_input;
49 inline void pop_input(void)
52 cur_input = input_stack[input_ptr];
54 inline void ensure_dvi_open(void)
56 if (output_file_name == 0)
61 pack_job_name(".dvi");
63 while (!b_open_out(dvi_file))
65 prompt_file_name("file name for output", ".dvi");
68 output_file_name = b_make_name_string(dvi_file);
72 inline void write_dvi(size_t a, size_t b)
74 if (fwrite((char *) &dvi_buf[a], sizeof(dvi_buf[a]),
75 ((b) - (a) + 1), dvi_file) != ((b) - (a) + 1))
76 FATAL_PERROR ("\n! dvi file");
78 inline void prompt_input(const char * s)
83 inline void synch_h(void)
87 movement(cur_h - dvi_h, right1);
91 inline void synch_v(void)
95 movement(cur_v - dvi_v, down1);
99 inline void set_cur_lang(void)
103 else if (language > 255)
108 inline void free_avail_(halfword p)
116 inline void dvi_out_(ASCII_code op)
118 dvi_buf[dvi_ptr] = op;
121 if (dvi_ptr == dvi_limit)
124 inline void succumb (void)
126 if (interaction == error_stop_mode)
127 interaction = scroll_mode;
139 history = error_stop_mode;
142 inline void flush_string (void)
145 pool_ptr = str_start[str_ptr];
147 inline void append_char (ASCII_code c)
149 str_pool[pool_ptr] = c;
152 inline void append_lc_hex (ASCII_code c)
155 append_char(c + '0');
157 append_char(c - 10 + 'a');
159 inline void print_err (const char * s)
161 if (interaction == error_stop_mode);
166 inline void tex_help (unsigned int n, ...)
175 va_start(help_arg, n);
177 for (i = n - 1; i > -1; --i)
178 help_line[i] = va_arg(help_arg, char *);
182 inline void str_room(int val)
184 #ifdef ALLOCATESTRING
185 if (pool_ptr + val > current_pool_size)
186 str_pool = realloc_str_pool(increment_pool_size);
188 if (pool_ptr + val > current_pool_size)
189 overflow("pool size", current_pool_size - init_pool_ptr);
191 if (pool_ptr + val > pool_size)
192 overflow("pool size", pool_size - init_pool_ptr);
195 inline void tail_append_ (pointer val)