about summary refs log tree commit diff
path: root/src/libstd/io/stdio.rs
AgeCommit message (Collapse)AuthorLines
2016-11-01std: Move a plattform-specific constant to sys::stdioBrian Anderson-9/+1
2016-10-01std: Move platform specific stdio code into sysBrian Anderson-5/+2
2016-09-30Change the sigs of set_print/set_panic to allow restoring the default objectsBrian Anderson-4/+4
2016-09-30Ignore lots and lots of std tests on emscriptenBrian Anderson-0/+1
2016-08-24Use `#[prelude_import]` in `libstd`.Jeffrey Seyfried-1/+0
2016-07-30Add doc example for StdoutGuillaume Gomez-0/+15
2016-07-30Add doc example for StdinGuillaume Gomez-0/+15
2016-07-30Add doc example for io::StderrGuillaume Gomez-0/+15
2016-03-23doc: Stdin is locked for reads, not writesBrian Anderson-2/+2
2016-03-10Fixup stout/stderr on WindowsOliver Middleton-19/+2
WriteConsoleW can fail if called with a large buffer so we need to slice any stdout/stderr output. However the current slicing has a few problems: 1. It slices by byte but still expects valid UTF-8. 2. The slicing happens even when not outputting to a console. 3. panic! output is not sliced. This fixes these issues by moving the slice to right before WriteConsoleW and slicing on a char boundary.
2016-03-08std: Funnel read_to_end through to one locationAlex Crichton-2/+10
This pushes the implementation detail of proxying `read_to_end` through to `read_to_end_uninitialized` all the way down to the `FileDesc` and `Handle` implementations on Unix/Windows. This way intermediate layers will also be able to take advantage of this optimized implementation. This commit also adds the optimized implementation for `ChildStdout` and `ChildStderr`.
2016-01-25std: Fix some behavior without stdio handlesAlex Crichton-1/+1
On all platforms, reading from stdin where the actual stdin isn't present should return 0 bytes as having been read rather than the entire buffer. On Windows, handle the case where we're inheriting stdio handles but one of them isn't present. Currently the behavior is to fail returning an I/O error but instead this commit corrects it to detecting this situation and propagating the non-set handle. Closes #31167
2015-12-30doc: missed these in a4da9acTshepang Lekhonkhobe-2/+2
2015-12-30doc: add gravesTshepang Lekhonkhobe-23/+23
2015-12-30doc: add some links for io::stdioTshepang Lekhonkhobe-14/+35
2015-12-23doc: make line visibleTshepang Lekhonkhobe-1/+1
2015-11-09std: Migrate to the new libcAlex Crichton-3/+2
* Delete `sys::unix::{c, sync}` as these are now all folded into libc itself * Update all references to use `libc` as a result. * Update all references to the new flat namespace. * Moves all windows bindings into sys::c
2015-10-31std: Prevent print panics when using TLSAlex Crichton-8/+26
Currently if a print happens while a thread is being torn down it may cause a panic if the LOCAL_STDOUT TLS slot has been destroyed by that point. This adds a guard to check and prints to the process stdout if that's the case (as we do for if the slot is already borrowed). Closes #29488
2015-10-08typos: fix a grabbag of typos all over the placeCristi Cobzarenco-3/+3
2015-08-30Auto merge of #27588 - cesarb:read_all, r=alexcrichtonbors-0/+3
This implements the proposed "read_exact" RFC (https://github.com/rust-lang/rfcs/pull/980). Tracking issue: https://github.com/rust-lang/rust/issues/27585
2015-08-24Implement read_exact for the Read traitCesar Eduardo Barros-0/+3
This implements the proposed "read_exact" RFC (https://github.com/rust-lang/rfcs/pull/980).
2015-08-15std: Add issues to all unstable featuresAlex Crichton-3/+6
2015-08-11correct copy/paste typos in stdio.rs commentsAlex Burka-4/+4
I'm not 100% sure lines 63 and 73 are typos.
2015-07-31Auto merge of #26897 - RalfJung:stdin-mut, r=alexcrichtonbors-1/+1
This fixes #26890. To be honest, the local compile-test is still running. This just takes so long. But this looks trivial enough...
2015-07-15Add specializations of read_to_end for Stdin, TcpStream and File,Alisdair Owens-0/+4
allowing them to read into a buffer containing uninitialized data, rather than pay the cost of zeroing.
2015-07-10Add more std::io documentation.Steve Klabnik-15/+97
This round: io::Result and the free functions.
2015-07-08Stdin::read_line: read_line does not need a mutable borrowRalf Jung-1/+1
2015-06-30doc: add example for Stdin::read_lineTshepang Lekhonkhobe-0/+22
2015-06-14Implement RFC 1014Steven Fackler-19/+77
Closes #25977 The various `stdfoo_raw` methods in std::io now return `io::Result`s, since they may not exist on Windows. They will always return `Ok` on Unix-like platforms. [breaking-change]
2015-05-27Use `const fn` to abstract away the contents of UnsafeCell & friends.Eduard Burtescu-3/+3
2015-05-09Squeeze the last bits of `task`s in documentation in favor of `thread`Barosl Lee-6/+6
An automated script was run against the `.rs` and `.md` files, subsituting every occurrence of `task` with `thread`. In the `.rs` files, only the texts in the comment blocks were affected.
2015-04-24Change name of unit test sub-module to "tests".Johannes Oertel-1/+1
Changes the style guidelines regarding unit tests to recommend using a sub-module named "tests" instead of "test" for unit tests as "test" might clash with imports of libtest.
2015-04-22Explain how to create a Stdin or StdoutMatt Brubeck-0/+4
2015-04-13pluralize doc comment verbs and add missing periodsAndrew Paseltiner-7/+7
2015-04-08Implement reentrant mutexes and make stdio use themSimonas Kazlauskas-17/+25
write_fmt calls write for each formatted field. The default implementation of write_fmt is used, which will call write on not-yet-locked stdout (and write locking after), therefore making print! in multithreaded environment still interleave contents of two separate prints. This patch implements reentrant mutexes, changes stdio handles to use these mutexes and overrides write_fmt to lock the stdio handle for the whole duration of the call.
2015-03-27std: Don't deadlock/panic on recursive printsAlex Crichton-11/+13
Previously a panic was generated for recursive prints due to a double-borrow of a `RefCell`. This was solved by the second borrow's output being directed towards the global stdout instead of the per-thread stdout (still experimental functionality). After this functionality was altered, however, recursive prints still deadlocked due to the overridden `write_fmt` method which locked itself first and then wrote all the data. This was fixed by removing the override of the `write_fmt` method. This means that unlocked usage of `write!` on a `Stdout`/`Stderr` may be slower due to acquiring more locks, but it's easy to make more performant with a call to `.lock()`. Closes #23781
2015-03-19Auto merge of #23507 - jbcrail:fix-comment-spelling, r=alexcrichtonbors-1/+1
I corrected misspelled comments in several crates.
2015-03-19Fix spelling errors in comments.Joseph Crail-1/+1
I corrected misspelled comments in several crates.
2015-03-18Add a testSteven Fackler-0/+26
2015-03-17Ignore stdio mutex poison stateSteven Fackler-3/+3
Nothing inside of the read/write interface itself can panic, so any poison must have been the result of user code which the lock isn't protecting.
2015-03-15Auto merge of #23206 - nagisa:print-io, r=alexcrichtonbors-5/+47
r? @alexcrichton or @aturon This still needs to somehow figure out how to avoid unstable warnings arising from the use of unstable functions. I tried to use `#[allow_internal_unstable]` but it still spits out warnings as far as I can see. @huonw (I think you implemented it) does `#[allow_internal_unstable]` not work for some reason or am I using it incorrectly?
2015-03-14Remove incorrect references to _raw stdio functionsKevin Ballard-18/+9
std::io does not currently expose the stdin_raw, stdout_raw, or stderr_raw functions. According to the current plans for stdio (see RFC #517), raw access will likely be provided using the platform-specific std::os::{unix,windows} modules. At the moment we don't expose any way to do this. As such, delete all mention of the _raw functions from the stdin/stdout/stderr function documentation. While we're at it, remove a few `pub`s from items that aren't exposed. This is done just to lessen the confusion experienced by anyone who looks at the source in an attempt to find the _raw functions.
2015-03-15Use new io in print and println macrosesSimonas Kazlauskas-5/+47
2015-03-13Fallout of std::old_io deprecationAlex Crichton-0/+23
2015-03-12std: Stabilize the `io` moduleAlex Crichton-4/+30
The new `std::io` module has had some time to bake now, and this commit stabilizes its functionality. There are still portions of the module which remain unstable, and below contains a summart of the actions taken. This commit also deprecates the entire contents of the `old_io` module in a blanket fashion. All APIs should now have a reasonable replacement in the new I/O modules. Stable APIs: * `std::io` (the name) * `std::io::prelude` (the name) * `Read` * `Read::read` * `Read::{read_to_end, read_to_string}` after being modified to return a `usize` for the number of bytes read. * `Write` * `Write::write` * `Write::{write_all, write_fmt}` * `BufRead` * `BufRead::{fill_buf, consume}` * `BufRead::{read_line, read_until}` after being modified to return a `usize` for the number of bytes read. * `BufReader` * `BufReader::{new, with_capacity}` * `BufReader::{get_ref, get_mut, into_inner}` * `{Read,BufRead} for BufReader` * `BufWriter` * `BufWriter::{new, with_capacity}` * `BufWriter::{get_ref, get_mut, into_inner}` * `Write for BufWriter` * `IntoInnerError` * `IntoInnerError::{error, into_inner}` * `{Error,Display} for IntoInnerError` * `LineWriter` * `LineWriter::{new, with_capacity}` - `with_capacity` was added * `LineWriter::{get_ref, get_mut, into_inner}` - `get_mut` was added) * `Write for LineWriter` * `BufStream` * `BufStream::{new, with_capacities}` * `BufStream::{get_ref, get_mut, into_inner}` * `{BufRead,Read,Write} for BufStream` * `stdin` * `Stdin` * `Stdin::lock` * `Stdin::read_line` - added method * `StdinLock` * `Read for Stdin` * `{Read,BufRead} for StdinLock` * `stdout` * `Stdout` * `Stdout::lock` * `StdoutLock` * `Write for Stdout` * `Write for StdoutLock` * `stderr` * `Stderr` * `Stderr::lock` * `StderrLock` * `Write for Stderr` * `Write for StderrLock` * `io::Result` * `io::Error` * `io::Error::last_os_error` * `{Display, Error} for Error` Unstable APIs: (reasons can be found in the commit itself) * `Write::flush` * `Seek` * `ErrorKind` * `Error::new` * `Error::from_os_error` * `Error::kind` Deprecated APIs * `Error::description` - available via the `Error` trait * `Error::detail` - available via the `Display` implementation * `thread::Builder::{stdout, stderr}` Changes in functionality: * `old_io::stdio::set_stderr` is now a noop as the infrastructure for printing backtraces has migrated to `std::io`. * The `ReadExt`, `WriteExt`, and `BufReadExt` extension traits were all removed by folding functionality into the corresponding trait. [breaking-change]
2015-03-06Fix an easy to trigger deadlock in std::io::stdioSimonas Kazlauskas-3/+0
Being a person who somehow has taken a liking to premature optimisation, my knee-jerk reaction to locking in std handles was preamble resembling following snippet: let stdout = stdout(); let lstdout = stdout.lock(); let stdin = stdin(); let lstdin = stdin.lock(); and then reading from the locked handle like this: let mut letter = [0; 1]; lstdin.read(&mut letter).unwrap(); As it is now this code will deadlock because the `read` method attempts to lock stdout as well!
2015-02-28std: Implement stdio for `std::io`Alex Crichton-0/+325
This is an implementation of RFC 899 and adds stdio functionality to the new `std::io` module. Details of the API can be found on the RFC, but from a high level: * `io::{stdin, stdout, stderr}` constructors are now available. There are also `*_raw` variants for unbuffered and unlocked access. * All handles are globally shared (excluding raw variants). * The stderr handle is no longer buffered. * All handles can be explicitly locked (excluding the raw variants). The `print!` and `println!` machinery has not yet been hooked up to these streams just yet. The `std::fmt::output` module has also not yet been implemented as part of this commit.
2015-01-26std: Rename io to old_ioAlex Crichton-566/+0
In preparation for the I/O rejuvination of the standard library, this commit renames the current `io` module to `old_io` in order to make room for the new I/O modules. It is expected that the I/O RFCs will land incrementally over time instead of all at once, and this provides a fresh clean path for new modules to enter into as well as guaranteeing that all old infrastructure will remain in place for some time. As each `old_io` module is replaced it will be deprecated in-place for new structures in `std::{io, fs, net}` (as appropriate). This commit does *not* leave a reexport of `old_io as io` as the deprecation lint does not currently warn on this form of use. This is quite a large breaking change for all imports in existing code, but all functionality is retained precisely as-is and path statements simply need to be renamed from `io` to `old_io`. [breaking-change]
2015-01-19Replace `0 as *const/mut T` with `ptr::null/null_mut()`we-1/+2
2015-01-06rollup merge of #20607: nrc/kindsAlex Crichton-1/+1
Conflicts: src/libcore/array.rs src/libcore/cell.rs src/libcore/prelude.rs src/libstd/path/posix.rs src/libstd/prelude/v1.rs src/test/compile-fail/dst-sized-trait-param.rs