[plt-scheme] MzScheme and read-line

From: Eric Swenson (eric at swenson.org)
Date: Fri Oct 2 12:23:50 EDT 2009

On Fri, Oct 2, 2009 at 9:21 AM, Eric Swenson <eric at swenson.org> wrote:

> Hello Chongkai,
> Thanks for your suggestions.  I tried this, but it didn't work.  In the
> case where (read-line) is returning "\r", I note that read-bytes-avail!* is
> returning 0, yet a subsequent read-line still returns "\r".  (I tried your
> example code exactly, and my-read-line returns "\r" as well.)  I wonder if
> this is a Win32 issue (line-ending issue) where some of the win32-specific
> support is not stripping the "\r" from the end-of-line sequence "\n\r"?
>
> Update: I tried this out on linux and your solution works fine.  But on
> Win32, it doesn't.  It would appear that some code doesn't know how to strip
> both the \n\r from the "text-mode" console.  Any suggestions?
>
> -- Eric
>
>
> On Thu, Oct 1, 2009 at 8:23 PM, Chongkai Zhu <czhu at cs.utah.edu> wrote:
>
>> (define flush-input
>>  (let ([buf (make-bytes 64)])
>>   (lambda ()
>>     (do ()
>>       ((zero? (read-bytes-avail!* buf)))))))
>>
>> (define (my-read-line)
>>  (begin (flush-input) (read-line)))
>>
>> Chongkai
>>
>> Eric Swenson wrote:
>>
>>> How do you get around this, then?  -- Eric
>>>
>>> On Thu, Oct 1, 2009 at 7:09 PM, Chongkai Zhu <czhu at cs.utah.edu <mailto:
>>> czhu at cs.utah.edu>> wrote:
>>>
>>>    This happens because the REPL will read one expression, so the newline
>>>    that follows it is still in the input buffer.
>>>
>>>
>>>
>>>
>>>    eswenson wrote:
>>>
>>>        Invoking (read-line) in DrScheme behaves as I would expect -- it
>>>        doesn't return until a newline is read.  However, invoking
>>>        (read-line)
>>>        in MzScheme (on Win7) return "\r" immediately without waiting
>>>        for any
>>>        input.  I've tried this before and after loading the GNU readline
>>>        support with no change in behavior.  I have verified that the
>>>        current
>>>        port is a terminal port in the interactive session and I've tried
>>>        starting MzScheme with and without "-i".  Thanks.
>>>
>>>        -- Eric
>>>        _________________________________________________
>>>         For list-related administrative tasks:
>>>         http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>>
>>>
>>>    _________________________________________________
>>>     For list-related administrative tasks:
>>>     http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20091002/aa948789/attachment.html>

Posted on the users mailing list.