about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2012-01-28 11:50:48 -0500
committerJosh Matthews <josh@joshmatthews.net>2012-01-28 11:50:48 -0500
commita831e7ce13aa19acf0f65e508097351f8dabca84 (patch)
treee8b14ee2373337d3867ee573d61227387191c962 /src/libstd
parentfcb381410d59b89336a528103582a956334c9777 (diff)
parent0794195fbdb6efa34388dfdf3dfc968bbbf06215 (diff)
downloadrust-a831e7ce13aa19acf0f65e508097351f8dabca84.tar.gz
rust-a831e7ce13aa19acf0f65e508097351f8dabca84.zip
Merge remote-tracking branch 'mozilla/master'
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/freebsd_os.rs3
-rw-r--r--src/libstd/generic_os.rs2
-rw-r--r--src/libstd/io.rs11
-rw-r--r--src/libstd/linux_os.rs3
-rw-r--r--src/libstd/list.rs2
-rw-r--r--src/libstd/macos_os.rs3
-rw-r--r--src/libstd/run_program.rs4
-rw-r--r--src/libstd/uvtmp.rs18
-rw-r--r--src/libstd/win32_os.rs3
9 files changed, 34 insertions, 15 deletions
diff --git a/src/libstd/freebsd_os.rs b/src/libstd/freebsd_os.rs
index 847262ca10c..89aad5d7777 100644
--- a/src/libstd/freebsd_os.rs
+++ b/src/libstd/freebsd_os.rs
@@ -129,7 +129,8 @@ fn dylib_filename(base: str) -> str { ret "lib" + base + ".so"; }
 /// followed by a path separator
 fn get_exe_path() -> option::t<fs::path> unsafe {
     let bufsize = 1023u;
-    let path = str::unsafe_from_bytes(vec::init_elt(bufsize, 0u8));
+    // FIXME: path "strings" will likely need fixing...
+    let path = str::from_bytes(vec::init_elt(bufsize, 0u8));
     let mib = [libc_constants::CTL_KERN,
                libc_constants::KERN_PROC,
                libc_constants::KERN_PROC_PATHNAME, -1i32];
diff --git a/src/libstd/generic_os.rs b/src/libstd/generic_os.rs
index 750b333f1a6..934352e7788 100644
--- a/src/libstd/generic_os.rs
+++ b/src/libstd/generic_os.rs
@@ -75,7 +75,7 @@ fn getenv(n: str) -> option::t<str> {
             unsafe {
                 vec::unsafe::set_len(v, res);
             }
-            ret option::some(str::unsafe_from_bytes(v));
+            ret option::some(str::from_bytes(v)); // UTF-8 or fail
         } else { nsize = res; }
     }
     fail;
diff --git a/src/libstd/io.rs b/src/libstd/io.rs
index 1db355dd385..5cc08813d6a 100644
--- a/src/libstd/io.rs
+++ b/src/libstd/io.rs
@@ -109,7 +109,7 @@ impl reader_util for reader {
             if ch == -1 || ch == 10 { break; }
             buf += [ch as u8];
         }
-        str::unsafe_from_bytes(buf)
+        str::from_bytes(buf)
     }
 
     fn read_c_str() -> str {
@@ -118,7 +118,7 @@ impl reader_util for reader {
             let ch = self.read_byte();
             if ch < 1 { break; } else { buf += [ch as u8]; }
         }
-        str::unsafe_from_bytes(buf)
+        str::from_bytes(buf)
     }
 
     // FIXME deal with eof?
@@ -461,7 +461,10 @@ fn mk_mem_buffer() -> mem_buffer {
 }
 fn mem_buffer_writer(b: mem_buffer) -> writer { b as writer }
 fn mem_buffer_buf(b: mem_buffer) -> [u8] { vec::from_mut(b.buf) }
-fn mem_buffer_str(b: mem_buffer) -> str { str::unsafe_from_bytes(b.buf) }
+fn mem_buffer_str(b: mem_buffer) -> str {
+   let b_ = vec::from_mut(b.buf);
+   str::from_bytes(b_)
+}
 
 // Utility functions
 fn seek_in_buf(offset: int, pos: uint, len: uint, whence: seek_style) ->
@@ -479,7 +482,7 @@ fn seek_in_buf(offset: int, pos: uint, len: uint, whence: seek_style) ->
 
 fn read_whole_file_str(file: str) -> result::t<str, str> {
     result::chain(read_whole_file(file), { |bytes|
-        result::ok(str::unsafe_from_bytes(bytes))
+        result::ok(str::from_bytes(bytes))
     })
 }
 
diff --git a/src/libstd/linux_os.rs b/src/libstd/linux_os.rs
index 7bc0212c1c2..82b1197a51f 100644
--- a/src/libstd/linux_os.rs
+++ b/src/libstd/linux_os.rs
@@ -125,7 +125,8 @@ fn dylib_filename(base: str) -> str { ret "lib" + base + ".so"; }
 /// followed by a path separator
 fn get_exe_path() -> option::t<fs::path> {
     let bufsize = 1023u;
-    let path = str::unsafe_from_bytes(vec::init_elt(bufsize, 0u8));
+    // FIXME: path "strings" will likely need fixing...
+    let path = str::from_bytes(vec::init_elt(bufsize, 0u8));
     ret str::as_buf("/proc/self/exe", { |proc_self_buf|
         str::as_buf(path, { |path_buf|
             if libc::readlink(proc_self_buf, path_buf, bufsize) != -1 {
diff --git a/src/libstd/list.rs b/src/libstd/list.rs
index 2081a21de23..e393b42b9f2 100644
--- a/src/libstd/list.rs
+++ b/src/libstd/list.rs
@@ -128,7 +128,7 @@ Function: tail
 
 Returns all but the first element of a list
 */
-pure fn tail<T: copy>(ls: list<T>) : is_not_empty(ls) -> list<T> {
+pure fn tail<T: copy>(ls: list<T>) -> list<T> {
     alt ls {
         cons(_, tl) { ret *tl; }
         nil { fail "list empty" }
diff --git a/src/libstd/macos_os.rs b/src/libstd/macos_os.rs
index b72fc732379..cd984870781 100644
--- a/src/libstd/macos_os.rs
+++ b/src/libstd/macos_os.rs
@@ -133,8 +133,9 @@ fn dylib_filename(base: str) -> str { ret "lib" + base + ".dylib"; }
 
 fn get_exe_path() -> option::t<fs::path> {
     // FIXME: This doesn't handle the case where the buffer is too small
+    // FIXME: path "strings" will likely need fixing...
     let bufsize = 1023u32;
-    let path = str::unsafe_from_bytes(vec::init_elt(bufsize as uint, 0u8));
+    let path = str::from_bytes(vec::init_elt(bufsize as uint, 0u8));
     ret str::as_buf(path, { |path_buf|
         if mac_libc::_NSGetExecutablePath(path_buf,
                                           ptr::mut_addr_of(bufsize)) == 0i32 {
diff --git a/src/libstd/run_program.rs b/src/libstd/run_program.rs
index e40526b5884..5b2de1e57d0 100644
--- a/src/libstd/run_program.rs
+++ b/src/libstd/run_program.rs
@@ -216,7 +216,7 @@ fn read_all(rd: io::reader) -> str {
     let buf = "";
     while !rd.eof() {
         let bytes = rd.read_bytes(4096u);
-        buf += str::unsafe_from_bytes(bytes);
+        buf += str::from_bytes(bytes);
     }
     ret buf;
 }
@@ -347,7 +347,7 @@ mod tests {
             let buf = "";
             while !reader.eof() {
                 let bytes = reader.read_bytes(4096u);
-                buf += str::unsafe_from_bytes(bytes);
+                buf += str::from_bytes(bytes);
             }
             os::fclose(file);
             ret buf;
diff --git a/src/libstd/uvtmp.rs b/src/libstd/uvtmp.rs
index fb9df4bfbd3..ae08cd5ed5e 100644
--- a/src/libstd/uvtmp.rs
+++ b/src/libstd/uvtmp.rs
@@ -27,6 +27,11 @@ native mod rustrt {
         thread: thread,
         req_id: u32,
         chan: comm::chan<iomsg>);
+    fn rust_uvtmp_timer(
+        thread: thread,
+        timeout: u32,
+        req_id: u32,
+        chan: comm::chan<iomsg>);
     fn rust_uvtmp_delete_buf(buf: *u8);
     fn rust_uvtmp_get_req_id(cd: connect_data) -> u32;
 }
@@ -39,7 +44,9 @@ enum iomsg {
     whatever,
     connected(connect_data),
     wrote(connect_data),
-    read(connect_data, *u8, ctypes::ssize_t)
+    read(connect_data, *u8, ctypes::ssize_t),
+    timer(u32),
+    exit
 }
 
 fn create_thread() -> thread {
@@ -80,6 +87,11 @@ fn read_start(thread: thread, req_id: u32,
     rustrt::rust_uvtmp_read_start(thread, req_id, chan);
 }
 
+fn timer_start(thread: thread, timeout: u32, req_id: u32,
+              chan: comm::chan<iomsg>) {
+    rustrt::rust_uvtmp_timer(thread, timeout, req_id, chan);
+}
+
 fn delete_buf(buf: *u8) {
     rustrt::rust_uvtmp_delete_buf(buf);
 }
@@ -138,7 +150,7 @@ fn test_http() {
                     unsafe {
                         log(error, len);
                         let buf = vec::unsafe::from_buf(buf, len as uint);
-                        let str = str::unsafe_from_bytes(buf);
+                        let str = str::from_bytes(buf);
                         #error("read something");
                         io::println(str);
                     }
@@ -153,4 +165,4 @@ fn test_http() {
     }
     join_thread(thread);
     delete_thread(thread);
-}
\ No newline at end of file
+}
diff --git a/src/libstd/win32_os.rs b/src/libstd/win32_os.rs
index 949c818a7ed..83306c757a4 100644
--- a/src/libstd/win32_os.rs
+++ b/src/libstd/win32_os.rs
@@ -113,8 +113,9 @@ fn getcwd() -> str { ret rustrt::rust_getcwd(); }
 
 fn get_exe_path() -> option::t<fs::path> {
     // FIXME: This doesn't handle the case where the buffer is too small
+    // FIXME: path "strings" will likely need fixing...
     let bufsize = 1023u;
-    let path = str::unsafe_from_bytes(vec::init_elt(bufsize, 0u8));
+    let path = str::from_bytes(vec::init_elt(bufsize, 0u8));
     ret str::as_buf(path, { |path_buf|
         if kernel32::GetModuleFileNameA(0u, path_buf,
                                         bufsize as u32) != 0u32 {