diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-08-25 18:42:36 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-08-25 18:43:38 -0700 |
| commit | ed1ab9a598fa2644d6a61ff35d04b680cd21cd67 (patch) | |
| tree | 1d04d43a3922e408d0ae0dbccf83ca16af572b4a /src/libcore | |
| parent | 7d86429415451f98e47b3fe374368888d62459e4 (diff) | |
libstd: Don't make task-local GC data when creating TCP streams.
This exposed an ICE in a test; it's commented out for now.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/io.rs | 29 | ||||
| -rw-r--r-- | src/libcore/run.rs | 1 |
2 files changed, 19 insertions, 11 deletions
diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 452aae49984..3855f4feb75 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -43,7 +43,12 @@ trait Reader { // Generic utility functions defined on readers -impl Reader { +trait ReaderUtil { + fn read_bytes(len: uint) -> ~[u8]; + fn read_line() -> ~str; +} + +impl<T: Reader> T : ReaderUtil { fn read_bytes(len: uint) -> ~[u8] { let mut buf = ~[mut]; vec::reserve(buf, len); @@ -54,6 +59,18 @@ impl Reader { unsafe { vec::unsafe::set_len(buf, count); } vec::from_mut(buf) } + fn read_line() -> ~str { + let mut buf = ~[]; + loop { + let ch = self.read_byte(); + if ch == -1 || ch == 10 { break; } + vec::push(buf, ch as u8); + } + str::from_bytes(buf) + } +} + +impl Reader { fn read_chars(n: uint) -> ~[char] { // returns the (consumed offset, n_req), appends characters to &chars fn chars_from_buf(buf: ~[u8], &chars: ~[char]) -> (uint, uint) { @@ -122,16 +139,6 @@ impl Reader { return c[0]; } - fn read_line() -> ~str { - let mut buf = ~[]; - loop { - let ch = self.read_byte(); - if ch == -1 || ch == 10 { break; } - vec::push(buf, ch as u8); - } - str::from_bytes(buf) - } - fn read_c_str() -> ~str { let mut buf: ~[u8] = ~[]; loop { diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 977119c0a56..0dba035e7b4 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -5,6 +5,7 @@ //! Process spawning import option::{some, none}; import libc::{pid_t, c_void, c_int}; +import io::ReaderUtil; export Program; export run_program; |
