Jon Boone pushed to branch issue-143-ansi-compliance-failure-listen-extra-argument at cmucl / cmucl

Commits:

1 changed file:

Changes:

  • src/code/stream.lisp
    ... ... @@ -604,7 +604,7 @@
    604 604
     	   :skipped-char-form ()
    
    605 605
     	   :eof-detected-form (eof-or-lose stream eof-errorp eof-value))))))
    
    606 606
     
    
    607
    -(defun listen (&optional (stream *standard-input*) (width 1))
    
    607
    +(defun listen (&optional (stream *standard-input* stream-p) (width 1 width-p))
    
    608 608
       "Returns T if a character is available on the given Stream."
    
    609 609
       (declare (type streamlike stream))
    
    610 610
       (let ((stream (in-synonym-of stream)))
    
    ... ... @@ -612,9 +612,26 @@
    612 612
           ;; simple-stream
    
    613 613
           (stream::%listen stream width)
    
    614 614
           ;; lisp-stream
    
    615
    -      (or (/= (the fixnum (lisp-stream-in-index stream)) in-buffer-length)
    
    616
    -	  ;; Test for t explicitly since misc methods return :eof sometimes.
    
    617
    -	  (eq (funcall (lisp-stream-misc stream) stream :listen) t))
    
    615
    +      (let ((error-type 'simple-program-error)
    
    616
    +            (function-name 'listen)
    
    617
    +            (format-control ())
    
    618
    +            (format-arguments ()))
    
    619
    +        (if width-p
    
    620
    +          ;; since width provided, two possible cases:
    
    621
    +          (progn
    
    622
    +            (if stream-p
    
    623
    +              ;; stream also provided, so too many arguments
    
    624
    +              (setf format-control (intl:gettext "Invalid number of arguments: ~S")
    
    625
    +                    format-arguments (list 3))
    
    626
    +              ;; stream init-form used, so invalid argument
    
    627
    +              (setf format-control (intl:gettext "Invalid argument: ~D")
    
    628
    +                    format-arguments (list 'width)))
    
    629
    +            (error error-type :function-name function-name
    
    630
    +                   :format-control format-control :format-arguments format-arguments))
    
    631
    +          ;; width not provided, so return expected value
    
    632
    +          (or (/= (the fixnum (lisp-stream-in-index stream)) in-buffer-length)
    
    633
    +            ;; Test for t explicitly since misc methods return :eof sometimes.
    
    634
    +            (eq (funcall (lisp-stream-misc stream) stream :listen) t))))
    
    618 635
           ;; fundamental-stream
    
    619 636
           (stream-listen stream))))
    
    620 637