about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-03-20 04:36:50 -0700
committerbors <bors@rust-lang.org>2014-03-20 04:36:50 -0700
commit95ee0a04fd78deb773da2d1b2544696c4f0278c7 (patch)
tree4d124c5ac9a515bc24bcba2c483b54ecd43e299e /src/libstd
parent4224147bab87a191cfc935e2e763889c11e63111 (diff)
parent8fee3f6f6e7155bb5316b2a6145ff3ef44c0824d (diff)
downloadrust-95ee0a04fd78deb773da2d1b2544696c4f0278c7.tar.gz
rust-95ee0a04fd78deb773da2d1b2544696c4f0278c7.zip
auto merge of #12980 : cmr/rust/overhaul-stdio, r=thestinger
this comes from a discussion on IRC where the split between stdin and stdout
seemed unnatural, and the fact that reading on stdin won't flush stdout, which
is unlike every other language (including C's stdio).
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io/stdio.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs
index 2389a8655f3..2f6cdcb5825 100644
--- a/src/libstd/io/stdio.rs
+++ b/src/libstd/io/stdio.rs
@@ -296,7 +296,13 @@ pub struct StdReader {
 impl Reader for StdReader {
     fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
         let ret = match self.inner {
-            TTY(ref mut tty) => tty.read(buf),
+            TTY(ref mut tty) => {
+                // Flush the task-local stdout so that weird issues like a
+                // print!'d prompt not being shown until after the user hits
+                // enter.
+                flush();
+                tty.read(buf)
+            },
             File(ref mut file) => file.read(buf).map(|i| i as uint),
         };
         match ret {