<br><br><div class="gmail_quote">On Fri, Oct 2, 2009 at 9:21 AM, Eric Swenson <span dir="ltr"><<a href="mailto:eric@swenson.org">eric@swenson.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello Chongkai,<div><br></div><div>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"? </div>
<div><br></div><div>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?</div>
<div><br></div><div><font color="#888888">-- Eric</font><div><div></div><div class="h5"><br><br><div class="gmail_quote">On Thu, Oct 1, 2009 at 8:23 PM, Chongkai Zhu <span dir="ltr"><<a href="mailto:czhu@cs.utah.edu" target="_blank">czhu@cs.utah.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
(define flush-input<br>
(let ([buf (make-bytes 64)])<br>
(lambda ()<br>
(do ()<br>
((zero? (read-bytes-avail!* buf)))))))<br>
<br>
(define (my-read-line)<br>
(begin (flush-input) (read-line)))<br>
<br>
Chongkai<br>
<br>
Eric Swenson wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
How do you get around this, then? -- Eric<br>
<br></div><div><div></div><div>
On Thu, Oct 1, 2009 at 7:09 PM, Chongkai Zhu <<a href="mailto:czhu@cs.utah.edu" target="_blank">czhu@cs.utah.edu</a> <mailto:<a href="mailto:czhu@cs.utah.edu" target="_blank">czhu@cs.utah.edu</a>>> wrote:<br>
<br>
This happens because the REPL will read one expression, so the newline<br>
that follows it is still in the input buffer.<br>
<br>
<br>
<br>
<br>
eswenson wrote:<br>
<br>
Invoking (read-line) in DrScheme behaves as I would expect -- it<br>
doesn't return until a newline is read. However, invoking<br>
(read-line)<br>
in MzScheme (on Win7) return "\r" immediately without waiting<br>
for any<br>
input. I've tried this before and after loading the GNU readline<br>
support with no change in behavior. I have verified that the<br>
current<br>
port is a terminal port in the interactive session and I've tried<br>
starting MzScheme with and without "-i". Thanks.<br>
<br>
-- Eric<br>
_________________________________________________<br>
For list-related administrative tasks:<br>
<a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>
<br>
<br>
_________________________________________________<br>
For list-related administrative tasks:<br>
<a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>
<br>
<br>
</div></div></blockquote>
<br>
</blockquote></div><br></div></div></div>
</blockquote></div><br>