OSDN Git Service

print_string -> prints.
[putex/putex.git] / src / texsourc / yandy_inlines.c
1 /* Copyright 2014 Clerk Ma
2
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.
7
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.
12
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
16    02110-1301 USA.  */
17
18 #define EXTERN extern
19
20 #include "texd.h"
21
22 inline void update_terminal(void)
23 {
24 #ifndef _WINDOWS
25   fflush(stdout);
26 #endif
27 }
28
29 inline void check_full_save_stack(void)
30 {
31   if (save_ptr > max_save_stack)
32   {
33     max_save_stack = save_ptr;
34
35 #ifdef ALLOCATESAVESTACK
36     if (max_save_stack > current_save_size - 6)
37       save_stack = realloc_save_stack(increment_save_size);
38     
39     if (max_save_stack > current_save_size - 6)
40     {
41       overflow("save size", current_save_size);
42       return;
43     }
44 #else
45     if (max_save_stack > save_size - 6)
46     {
47       overflow("save size", save_size);
48       return;
49     }
50 #endif
51   }
52 }
53 inline void write_dvi(size_t a, size_t b)
54 {
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");
58 }
59 inline void prompt_input(const char * s)
60 {
61   prints(s);
62   term_input();
63 }
64 inline void set_cur_lang(void)
65 {
66   if (language <= 0)
67     cur_lang = 0;
68   else if (language > 255)
69     cur_lang = 0;
70   else
71     cur_lang = language;
72 }
73 inline void free_avail_(halfword p)
74 {
75   link(p) = avail;
76   avail = p;
77 #ifdef STAT
78   decr(dyn_used);
79 #endif
80 }
81 /* sec 0042 */
82 inline void append_char (ASCII_code c)
83 {
84   str_pool[pool_ptr] = c;
85   incr(pool_ptr);
86 }
87 /* sec 0042 */
88 inline void str_room(int val)
89 {
90 #ifdef ALLOCATESTRING
91   if (pool_ptr + val > current_pool_size)
92     str_pool = realloc_str_pool(increment_pool_size);
93
94   if (pool_ptr + val > current_pool_size)
95     overflow("pool size", current_pool_size - init_pool_ptr);
96 #else
97   if (pool_ptr + val > pool_size)
98     overflow("pool size", pool_size - init_pool_ptr);
99 #endif
100 }
101 /* sec 0044 */
102 inline void flush_string (void)
103 {
104   decr(str_ptr);
105   pool_ptr = str_start[str_ptr];
106 }
107 /* sec 0048 */
108 inline void append_lc_hex (ASCII_code c)
109 {
110   if (c < 10)
111     append_char(c + '0');
112   else
113     append_char(c - 10 + 'a');
114 }
115 /* sec 0073 */
116 inline void print_err (const char * s)
117 {
118   if (interaction == error_stop_mode);
119     print_nl("! ");
120
121   prints(s);
122 }
123 /* sec 0079 */
124 inline void tex_help (unsigned int n, ...)
125 {
126   int i;
127   va_list help_arg;
128
129   if (n > 6)
130     n = 6;
131
132   help_ptr = n;
133   va_start(help_arg, n);
134
135   for (i = n - 1; i > -1; --i)
136     help_line[i] = va_arg(help_arg, char *);
137
138   va_end(help_arg);
139 }
140 /* sec 0093 */
141 inline void succumb (void)
142 {
143   if (interaction == error_stop_mode)
144     interaction = scroll_mode;
145
146   if (log_opened)
147   {
148     error();
149   }
150
151 #ifdef DEBUG
152   if (interaction > 0)
153     debug_help();
154 #endif
155
156   history = error_stop_mode;
157   jump_out();
158 }
159 /* sec 0214 */
160 inline void tail_append_ (pointer val)
161 {
162   link(tail) = val;
163   tail = link(tail);
164 }
165 /* sec 0321 */
166 inline void push_input(void)
167 {
168   if (input_ptr > max_in_stack)
169   {
170     max_in_stack = input_ptr;
171
172 #ifdef ALLOCATEINPUTSTACK
173     if (input_ptr == current_stack_size)
174       input_stack = realloc_input_stack(increment_stack_size);
175     
176     if (input_ptr == current_stack_size)
177     {
178       overflow("input stack size", current_stack_size);
179       return;
180     }
181 #else
182     if (input_ptr == stack_size)
183     {
184       overflow("input stack size", stack_size);
185       return;
186     }
187 #endif
188   }
189   
190   input_stack[input_ptr] = cur_input;
191   incr(input_ptr);
192 }
193 /* sec 0322 */
194 inline void pop_input(void)
195 {
196   decr(input_ptr);
197   cur_input = input_stack[input_ptr];
198 }
199 /* sec 0532 */
200 inline void ensure_dvi_open(void)
201 {
202   if (output_file_name == 0)
203   {
204     if (job_name == 0)
205       open_log_file();
206
207     pack_job_name(".dvi");
208
209     while (!b_open_out(dvi_file))
210     {
211       prompt_file_name("file name for output", ".dvi");
212     }
213
214     output_file_name = b_make_name_string(dvi_file);
215   }
216 }
217 /* sec 0598 */
218 inline void dvi_out_(ASCII_code op)
219 {
220   dvi_buf[dvi_ptr] = op;
221   incr(dvi_ptr);
222
223   if (dvi_ptr == dvi_limit)
224     dvi_swap();
225 }
226 /* sec 0616 */
227 inline void synch_h(void)
228 {
229   if (cur_h != dvi_h)
230   {
231     movement(cur_h - dvi_h, right1);
232     dvi_h = cur_h;
233   }
234 }
235 /* sec 0616 */
236 inline void synch_v(void)
237 {
238   if (cur_v != dvi_v)
239   {
240     movement(cur_v - dvi_v, down1);
241     dvi_v = cur_v;
242   }
243 }