OSDN Git Service

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