From: Chris Hanson Date: Tue, 25 Apr 1989 02:25:10 +0000 (+0000) Subject: Change `xterm-read-chars': if called with non-false interval, and an X-Git-Tag: 20090517-FFI~12114 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=f4e9a102d89f573de4b800bf785128483972a06e;p=mit-scheme.git Change `xterm-read-chars': if called with non-false interval, and an event flag is set during that interval, return immediately. If no characters have been received, return the amount of the interval which remains, so the primitive can be continued by reentering it with this number as its argument. --- diff --git a/v7/src/microcode/version.h b/v7/src/microcode/version.h index 782788eb8..7472ca278 100644 --- a/v7/src/microcode/version.h +++ b/v7/src/microcode/version.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 10.74 1989/04/19 02:30:24 arthur Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 10.75 1989/04/25 02:25:10 cph Exp $ Copyright (c) 1988, 1989 Massachusetts Institute of Technology @@ -46,7 +46,7 @@ MIT in each case. */ #define VERSION 10 #endif #ifndef SUBVERSION -#define SUBVERSION 74 +#define SUBVERSION 75 #endif #ifndef UCODE_TABLES_FILENAME diff --git a/v7/src/microcode/x11term.c b/v7/src/microcode/x11term.c index 629c7c0ff..b628687d0 100644 --- a/v7/src/microcode/x11term.c +++ b/v7/src/microcode/x11term.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11term.c,v 1.2 1989/04/20 04:33:52 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11term.c,v 1.3 1989/04/25 02:24:20 cph Exp $ Copyright (c) 1989 Massachusetts Institute of Technology @@ -987,26 +987,25 @@ DEFINE_PRIMITIVE ("XTERM-READ-CHARS", Prim_xterm_read_chars, 2, 2, 0) interval = (((ARG_REF (2)) == SHARP_F) ? (-1) : (arg_nonnegative_integer (2))); if (interval >= 0) - time_limit = ((OS_real_time_clock ()) + (interval)); + time_limit = ((OS_real_time_clock ()) + interval); buffer_length = 4; buffer_index = 0; buffer = (xterm_malloc (buffer_length)); scan_buffer = buffer; while (1) { - if (interval < 0) - { - if (((XPending (display)) == 0) && - ((buffer != scan_buffer) || ((xt -> event_flags) != 0))) - break; - } - else + if ((XPending (display)) == 0) { if ((buffer != scan_buffer) || - ((OS_real_time_clock ()) >= time_limit)) + ((xt -> event_flags) != 0) || + (interval == 0)) break; - if ((XPending (display)) == 0) - continue; + if (interval > 0) + { + if ((OS_real_time_clock ()) >= time_limit) + break; + continue; + } } XNextEvent (display, (& event)); if ((event . type) != KeyPress) @@ -1040,9 +1039,16 @@ DEFINE_PRIMITIVE ("XTERM-READ-CHARS", Prim_xterm_read_chars, 2, 2, 0) (*scan_buffer++) = (*scan_copy++); buffer_index = (scan_buffer - buffer); } - if (buffer == scan_buffer) + /* If we got characters, return them */ + if (buffer != scan_buffer) + PRIMITIVE_RETURN (memory_to_string (buffer_index, buffer)); + /* If we're in a read with timeout, and we stopped before the + timeout was finished, return the amount remaining. */ + if (interval > 0) + interval = (time_limit - (OS_real_time_clock ())); + if (interval <= 0) PRIMITIVE_RETURN (SHARP_F); - PRIMITIVE_RETURN (memory_to_string (buffer_index, buffer)); + PRIMITIVE_RETURN (C_Integer_To_Scheme_Integer (interval)); } static void diff --git a/v8/src/microcode/version.h b/v8/src/microcode/version.h index a478a90d8..c46a92606 100644 --- a/v8/src/microcode/version.h +++ b/v8/src/microcode/version.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 10.74 1989/04/19 02:30:24 arthur Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 10.75 1989/04/25 02:25:10 cph Exp $ Copyright (c) 1988, 1989 Massachusetts Institute of Technology @@ -46,7 +46,7 @@ MIT in each case. */ #define VERSION 10 #endif #ifndef SUBVERSION -#define SUBVERSION 74 +#define SUBVERSION 75 #endif #ifndef UCODE_TABLES_FILENAME