/[cmucl]/src/code/stream.lisp
ViewVC logotype

Diff of /src/code/stream.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by ram, Tue Apr 23 12:58:28 1991 UTC revision 1.12 by chiles, Mon Jun 10 16:57:47 1991 UTC
# Line 1107  Line 1107 
1107         (funcall method sub-stream operation arg1 arg2)))))         (funcall method sub-stream operation arg1 arg2)))))
1108    
1109  (proclaim '(notinline read-char unread-char read-byte listen))  (proclaim '(notinline read-char unread-char read-byte listen))
1110    
1111    
1112    
1113    ;;;; Public interface from "EXTENSIONS" package.
1114    
1115    (in-package "EXT")
1116    
1117    (export '(get-stream-command stream-command stream-command-p stream-command-name
1118              stream-command-args make-stream-command))
1119    
1120    (defstruct (stream-command (:print-function print-stream-command)
1121                               (:constructor make-stream-command
1122                                             (name &optional args)))
1123      (name nil :type symbol)
1124      (args nil :type list))
1125    
1126    (defun print-stream-command (obj str n)
1127      (declare (ignore n))
1128      (format str "#<Stream-Cmd ~S>" (stream-command-name obj)))
1129    
1130    
1131    ;;; GET-STREAM-COMMAND -- Public.
1132    ;;;
1133    ;;; We can't simply call the stream's misc method because because nil is an
1134    ;;; ambiguous return value: does it mean text arrived, or does it mean the
1135    ;;; stream's misc method had no :get-command implementation.  We can't return
1136    ;;; nil until there is text input.  We don't need to loop because any stream
1137    ;;; implementing :get-command would wait until it had some input.  If the
1138    ;;; LISTEN fails, then we have some random stream we must wait on.
1139    ;;;
1140    (defun get-stream-command (stream)
1141      "This takes a stream and waits for text or a command to appear on it.  If
1142       text appears before a command, this returns nil, and otherwise it returns
1143       a command."
1144      (let ((cmdp (funcall (lisp::stream-misc stream) stream :get-command)))
1145        (cond (cmdp)
1146              ((listen stream)
1147               nil)
1148              (t
1149               ;; This waits for input and returns nil when it arrives.
1150               (unread-char (read-char stream) stream)))))

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.5