#include #include #include #include "mlvalues.h" #include "signals.h" #include "instruct.h" #include "fail.h" CODE raise_break_exn; static int catch_break = 0; value sys_catch_break(onoff) value onoff; { union REGS r; catch_break = Tag_val(onoff); r.x.ax = 0x3301; r.x.dx = catch_break ? 2 : 1; int86(0x21, &r, &r); return Atom(0); } void poll_break() { union REGS r; if (catch_break == 0) return; r.x.ax = 0x3303; int86(0x21, &r, &r); if (r.x.dx != 0) { signal_handler = raise_break_exn; signal_number = 0; execute_signal(); } } /* Special input function for MS-DOS (to take advantage of external line editors when reading from the console. */ static struct { unsigned char max_len; unsigned char act_len; char data[200]; } read_buffer; static int stdin_is_console = -1; static int stdin_at_eof = 0; /* Valid only if stdin_is_console==1 */ int msdos_read(fd, ptr, len) int fd; char * ptr; unsigned len; { if (fd == 0) { if (stdin_is_console == -1) { union REGS regs; regs.x.ax = 0x4400; regs.x.bx = fd; intdos(®s, ®s); stdin_is_console = (regs.x.dx & 0x81) == 0x81; } /* Modified for Moscow SML 1994-08-23 to detect control-Z = 0x1A */ if (stdin_is_console) if (stdin_at_eof) return 0; else { read_buffer.max_len = sizeof(read_buffer.data) - 1; if (len <= read_buffer.max_len) read_buffer.max_len = len - 1; if (bdosptr(0xA, &read_buffer, 0) != 0) poll_break(); bdos(0x2, '\n', 0); read_buffer.data[read_buffer.act_len] = '\n'; bcopy(read_buffer.data, ptr, read_buffer.act_len + 1); {int i; for (i=0; (i