-/* Copyright 2014 Clerk Ma
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301 USA. */
-
-#define EXTERN extern
-
-#include "yandytex.h"
-
-/* sec 0016 */
-void do_nothing(void)
-{
- /* todo */
-}
-/* sec 0034 */
-void update_terminal(void)
-{
- fflush(stdout);
-}
-/* sec 0042 */
-void append_char (ASCII_code c)
-{
- str_pool[pool_ptr] = c;
- incr(pool_ptr);
-}
-/* sec 0042 */
-void str_room(int val)
-{
-#ifdef ALLOCATESTRING
- if (pool_ptr + val > current_pool_size)
- str_pool = realloc_str_pool(increment_pool_size);
-
- if (pool_ptr + val > current_pool_size)
- overflow("pool size", current_pool_size - init_pool_ptr);
-#else
- if (pool_ptr + val > pool_size)
- overflow("pool size", pool_size - init_pool_ptr);
-#endif
-}
-/* sec 0044 */
-void flush_string (void)
-{
- decr(str_ptr);
- pool_ptr = str_start[str_ptr];
-}
-/* sec 0048 */
-void append_lc_hex (ASCII_code c)
-{
- if (c < 10)
- append_char(c + '0');
- else
- append_char(c - 10 + 'a');
-}
-/* sec 0056 */
-/* sec 0073 */
-void print_err (const char * s)
-{
- if (interaction == error_stop_mode)
- do_nothing();
-
- print_nl("! ");
- prints(s);
-}
-/* sec 0071 */
-void prompt_input(const char * s)
-{
- prints(s);
- term_input();
-}
-/* sec 0079 */
-void tex_help (unsigned int n, ...)
-{
- int i;
- va_list help_arg;
-
- if (n > 6)
- n = 6;
-
- help_ptr = n;
- va_start(help_arg, n);
-
- for (i = n - 1; i > -1; --i)
- help_line[i] = va_arg(help_arg, char *);
-
- va_end(help_arg);
-}
-/* sec 0093 */
-void succumb (void)
-{
- if (interaction == error_stop_mode)
- interaction = scroll_mode;
-
- if (log_opened)
- error();
-
-#ifdef DEBUG
- if (interaction > 0)
- debug_help();
-#endif
-
- history = error_stop_mode;
- jump_out();
-}
-/* sec 0121 */
-void free_avail_(halfword p)
-{
- link(p) = avail;
- avail = p;
-#ifdef STAT
- decr(dyn_used);
-#endif
-}
-/* sec 0180 */
-void node_list_display (integer p)
-{
- append_char('.');
- show_node_list(p);
- decr(pool_ptr);
-}
-/* sec 0214 */
-void tail_append_ (pointer val)
-{
- link(tail) = val;
- tail = link(tail);
-}
-/* sec 0273 */
-void check_full_save_stack(void)
-{
- if (save_ptr > max_save_stack)
- {
- max_save_stack = save_ptr;
-
-#ifdef ALLOCATESAVESTACK
- if (max_save_stack > current_save_size - 6)
- save_stack = realloc_save_stack(increment_save_size);
-
- if (max_save_stack > current_save_size - 6)
- {
- overflow("save size", current_save_size);
- return;
- }
-#else
- if (max_save_stack > save_size - 6)
- {
- overflow("save size", save_size);
- return;
- }
-#endif
- }
-}
-/* sec 0321 */
-void push_input(void)
-{
- if (input_ptr > max_in_stack)
- {
- max_in_stack = input_ptr;
-
-#ifdef ALLOCATEINPUTSTACK
- if (input_ptr == current_stack_size)
- input_stack = realloc_input_stack(increment_stack_size);
-
- if (input_ptr == current_stack_size)
- {
- overflow("input stack size", current_stack_size);
- return;
- }
-#else
- if (input_ptr == stack_size)
- {
- overflow("input stack size", stack_size);
- return;
- }
-#endif
- }
-
- input_stack[input_ptr] = cur_input;
- incr(input_ptr);
-}
-/* sec 0322 */
-void pop_input(void)
-{
- decr(input_ptr);
- cur_input = input_stack[input_ptr];
-}
-/* sec 0532 */
-void ensure_dvi_open (void)
-{
- if (output_file_name == 0)
- {
- if (job_name == 0)
- open_log_file();
-
- pack_job_name(".dvi");
-
- while (!b_open_out(dvi_file))
- prompt_file_name("file name for output", ".dvi");
-
- output_file_name = b_make_name_string(dvi_file);
- }
-}
-/* sec 0564 */
-void fget (void)
-{
- fbyte = getc(tfm_file);
-}
-/* sec 0597 */
-void write_dvi(size_t a, size_t b)
-{
- if (fwrite((char *)&dvi_buf[a], sizeof(dvi_buf[a]),
- (b - a + 1), dvi_file) != (b - a + 1))
- FATAL_PERROR("\n! dvi file");
-}
-/* sec 0598 */
-void dvi_out_(ASCII_code op)
-{
- dvi_buf[dvi_ptr] = op;
- incr(dvi_ptr);
-
- if (dvi_ptr == dvi_limit)
- dvi_swap();
-}
-/* sec 0616 */
-void synch_h (void)
-{
- if (cur_h != dvi_h)
- {
- movement(cur_h - dvi_h, right1);
- dvi_h = cur_h;
- }
-}
-/* sec 0616 */
-void synch_v (void)
-{
- if (cur_v != dvi_v)
- {
- movement(cur_v - dvi_v, down1);
- dvi_v = cur_v;
- }
-}
-/* sec 0934 */
-void set_cur_lang (void)
-{
- if (language <= 0)
- cur_lang = 0;
- else if (language > 255)
- cur_lang = 0;
- else
- cur_lang = language;
-}
-/* sec 0985 */
-void print_plus (int i, const char * s)
-{
- if (page_so_far[i] != 0)
- {
- prints(" plus ");
- print_scaled(page_so_far[i]);
- prints(s);
- }
+/* Copyright 2014 Clerk Ma\r
+\r
+ This program is free software; you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation; either version 2 of the License, or\r
+ (at your option) any later version.\r
+\r
+ This program is distributed in the hope that it will be useful, but\r
+ WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with this program; if not, write to the Free Software\r
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\r
+ 02110-1301 USA. */\r
+\r
+#define EXTERN extern\r
+\r
+#include "yandytex.h"\r
+\r
+/* sec 0016 */\r
+void do_nothing(void)\r
+{\r
+ /* todo */\r
+}\r
+/* sec 0034 */\r
+void update_terminal(void)\r
+{\r
+ fflush(stdout);\r
+}\r
+/* sec 0042 */\r
+void append_char (ASCII_code c)\r
+{\r
+ str_pool[pool_ptr] = c;\r
+ incr(pool_ptr);\r
+}\r
+/* sec 0042 */\r
+void str_room(int val)\r
+{\r
+#ifdef ALLOCATESTRING\r
+ if (pool_ptr + val > current_pool_size)\r
+ str_pool = realloc_str_pool(increment_pool_size);\r
+\r
+ if (pool_ptr + val > current_pool_size)\r
+ overflow("pool size", current_pool_size - init_pool_ptr);\r
+#else\r
+ if (pool_ptr + val > pool_size)\r
+ overflow("pool size", pool_size - init_pool_ptr);\r
+#endif\r
+}\r
+/* sec 0044 */\r
+void flush_string (void)\r
+{\r
+ decr(str_ptr);\r
+ pool_ptr = str_start[str_ptr];\r
+}\r
+/* sec 0048 */\r
+void append_lc_hex (ASCII_code c)\r
+{\r
+ if (c < 10)\r
+ append_char(c + '0');\r
+ else\r
+ append_char(c - 10 + 'a');\r
+}\r
+/* sec 0056 */\r
+/* sec 0073 */\r
+void print_err (const char * s)\r
+{\r
+ if (interaction == error_stop_mode)\r
+ do_nothing();\r
+ \r
+ print_nl("! ");\r
+ prints(s);\r
+}\r
+/* sec 0071 */\r
+void prompt_input(const char * s)\r
+{\r
+ prints(s);\r
+ term_input();\r
+}\r
+/* sec 0079 */\r
+void tex_help (unsigned int n, ...)\r
+{\r
+ int i;\r
+ va_list help_arg;\r
+\r
+ if (n > 6)\r
+ n = 6;\r
+\r
+ help_ptr = n;\r
+ va_start(help_arg, n);\r
+\r
+ for (i = n - 1; i > -1; --i)\r
+ help_line[i] = va_arg(help_arg, char *);\r
+\r
+ va_end(help_arg);\r
+}\r
+/* sec 0093 */\r
+void succumb (void)\r
+{\r
+ if (interaction == error_stop_mode)\r
+ interaction = scroll_mode;\r
+\r
+ if (log_opened)\r
+ error();\r
+\r
+#ifdef DEBUG\r
+ if (interaction > 0)\r
+ debug_help();\r
+#endif\r
+\r
+ history = error_stop_mode;\r
+ jump_out();\r
+}\r
+/* sec 0121 */\r
+void free_avail_(halfword p)\r
+{\r
+ link(p) = avail;\r
+ avail = p;\r
+#ifdef STAT\r
+ decr(dyn_used);\r
+#endif\r
+}\r
+/* sec 0180 */\r
+void node_list_display (integer p)\r
+{\r
+ append_char('.');\r
+ show_node_list(p);\r
+ decr(pool_ptr);\r
+}\r
+/* sec 0214 */\r
+void tail_append_ (pointer val)\r
+{\r
+ link(tail) = val;\r
+ tail = link(tail);\r
+}\r
+/* sec 0273 */\r
+void check_full_save_stack(void)\r
+{\r
+ if (save_ptr > max_save_stack)\r
+ {\r
+ max_save_stack = save_ptr;\r
+\r
+#ifdef ALLOCATESAVESTACK\r
+ if (max_save_stack > current_save_size - 6)\r
+ save_stack = realloc_save_stack(increment_save_size);\r
+\r
+ if (max_save_stack > current_save_size - 6)\r
+ {\r
+ overflow("save size", current_save_size);\r
+ return;\r
+ }\r
+#else\r
+ if (max_save_stack > save_size - 6)\r
+ {\r
+ overflow("save size", save_size);\r
+ return;\r
+ }\r
+#endif\r
+ }\r
+}\r
+/* sec 0321 */\r
+void push_input(void)\r
+{\r
+ if (input_ptr > max_in_stack)\r
+ {\r
+ max_in_stack = input_ptr;\r
+\r
+#ifdef ALLOCATEINPUTSTACK\r
+ if (input_ptr == current_stack_size)\r
+ input_stack = realloc_input_stack(increment_stack_size);\r
+ \r
+ if (input_ptr == current_stack_size)\r
+ {\r
+ overflow("input stack size", current_stack_size);\r
+ return;\r
+ }\r
+#else\r
+ if (input_ptr == stack_size)\r
+ {\r
+ overflow("input stack size", stack_size);\r
+ return;\r
+ }\r
+#endif\r
+ }\r
+ \r
+ input_stack[input_ptr] = cur_input;\r
+ incr(input_ptr);\r
+}\r
+/* sec 0322 */\r
+void pop_input(void)\r
+{\r
+ decr(input_ptr);\r
+ cur_input = input_stack[input_ptr];\r
+}\r
+/* sec 0532 */\r
+void ensure_dvi_open (void)\r
+{\r
+ if (output_file_name == 0)\r
+ {\r
+ if (job_name == 0)\r
+ open_log_file();\r
+\r
+ pack_job_name(".dvi");\r
+\r
+ while (!b_open_out(dvi_file))\r
+ prompt_file_name("file name for output", ".dvi");\r
+\r
+ output_file_name = b_make_name_string(dvi_file);\r
+ }\r
+}\r
+/* sec 0564 */\r
+void fget (void)\r
+{\r
+ fbyte = getc(tfm_file);\r
+}\r
+/* sec 0597 */\r
+void write_dvi(size_t a, size_t b)\r
+{\r
+ if (fwrite((char *)&dvi_buf[a], sizeof(dvi_buf[a]),\r
+ (b - a + 1), dvi_file) != (b - a + 1))\r
+ FATAL_PERROR("\n! dvi file");\r
+}\r
+/* sec 0598 */\r
+void dvi_out_(ASCII_code op)\r
+{\r
+ dvi_buf[dvi_ptr] = op;\r
+ incr(dvi_ptr);\r
+\r
+ if (dvi_ptr == dvi_limit)\r
+ dvi_swap();\r
+}\r
+/* sec 0616 */\r
+void synch_h (void)\r
+{\r
+ if (cur_h != dvi_h)\r
+ {\r
+ movement(cur_h - dvi_h, right1);\r
+ dvi_h = cur_h;\r
+ }\r
+}\r
+/* sec 0616 */\r
+void synch_v (void)\r
+{\r
+ if (cur_v != dvi_v)\r
+ {\r
+ movement(cur_v - dvi_v, down1);\r
+ dvi_v = cur_v;\r
+ }\r
+}\r
+/* sec 0934 */\r
+void set_cur_lang (void)\r
+{\r
+ if (language <= 0)\r
+ cur_lang = 0;\r
+ else if (language > 255)\r
+ cur_lang = 0;\r
+ else\r
+ cur_lang = language;\r
+}\r
+/* sec 0985 */\r
+void print_plus (int i, const char * s)\r
+{\r
+ if (page_so_far[i] != 0)\r
+ {\r
+ prints(" plus ");\r
+ print_scaled(page_so_far[i]);\r
+ prints(s);\r
+ }\r
}
\ No newline at end of file