about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-08-11 17:02:13 -0700
committerBrian Anderson <banderson@mozilla.com>2011-08-12 12:08:26 -0700
commita9ce342fa384b3c1f86e9b3a80ec7b30a87d2e65 (patch)
tree94e3672f0e08e1a56cc4ce44d803f85bf38c892b /src
parent49b80f9bf7a3d72a58111b9d753a777411c7ad4a (diff)
downloadrust-a9ce342fa384b3c1f86e9b3a80ec7b30a87d2e65.tar.gz
rust-a9ce342fa384b3c1f86e9b3a80ec7b30a87d2e65.zip
Convert all uses of unsafe_from_bytes to unsafe_from_bytes_ivec
Diffstat (limited to 'src')
-rw-r--r--src/comp/middle/trans.rs4
-rw-r--r--src/comp/syntax/parse/lexer.rs6
-rw-r--r--src/comp/syntax/print/pprust.rs4
-rw-r--r--src/comp/util/ppaux.rs2
-rw-r--r--src/lib/extfmt.rs6
-rw-r--r--src/lib/io.rs8
-rw-r--r--src/lib/ivec.rs2
-rw-r--r--src/lib/run_program.rs4
-rw-r--r--src/test/compiletest/procsrv.rs4
-rw-r--r--src/test/stdtest/run.rs5
-rw-r--r--src/test/stdtest/vec_str_conversions.rs13
11 files changed, 27 insertions, 31 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 36d496111a8..ede46df6df5 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -311,8 +311,8 @@ fn sanitize(s: &str) -> str {
                     if c != 10u8 && c != '}' as u8 && c != ')' as u8 &&
                            c != ' ' as u8 && c != '\t' as u8 && c != ';' as u8
                        {
-                        let v = [c];
-                        result += str::unsafe_from_bytes(v);
+                        let v = ~[c];
+                        result += str::unsafe_from_bytes_ivec(v);
                     }
                 }
             }
diff --git a/src/comp/syntax/parse/lexer.rs b/src/comp/syntax/parse/lexer.rs
index b101f274858..04939ad0ecd 100644
--- a/src/comp/syntax/parse/lexer.rs
+++ b/src/comp/syntax/parse/lexer.rs
@@ -177,11 +177,11 @@ fn scan_exponent(rdr: &reader) -> option::t[str] {
     let c = rdr.curr();
     let rslt = "";
     if c == 'e' || c == 'E' {
-        rslt += str::unsafe_from_bytes([c as u8]);
+        rslt += str::unsafe_from_bytes_ivec(~[c as u8]);
         rdr.bump();
         c = rdr.curr();
         if c == '-' || c == '+' {
-            rslt += str::unsafe_from_bytes([c as u8]);
+            rslt += str::unsafe_from_bytes_ivec(~[c as u8]);
             rdr.bump();
         }
         let exponent = scan_dec_digits(rdr);
@@ -195,7 +195,7 @@ fn scan_dec_digits(rdr: &reader) -> str {
     let c = rdr.curr();
     let rslt: str = "";
     while is_dec_digit(c) || c == '_' {
-        if c != '_' { rslt += str::unsafe_from_bytes([c as u8]); }
+        if c != '_' { rslt += str::unsafe_from_bytes_ivec(~[c as u8]); }
         rdr.bump();
         c = rdr.curr();
     }
diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs
index 0730c98d6c2..6d89bc325de 100644
--- a/src/comp/syntax/print/pprust.rs
+++ b/src/comp/syntax/print/pprust.rs
@@ -1385,8 +1385,8 @@ fn print_literal(s: &ps, lit: &@ast::lit) {
         print_string(s, st);
       }
       ast::lit_char(ch) {
-        word(s.s, "'" +
-             escape_str(str::unsafe_from_bytes([ch as u8]), '\'') + "'");
+        word(s.s, "'" + escape_str(
+            str::unsafe_from_bytes_ivec(~[ch as u8]), '\'') + "'");
       }
       ast::lit_int(val) { word(s.s, int::str(val)); }
       ast::lit_uint(val) { word(s.s, uint::str(val) + "u"); }
diff --git a/src/comp/util/ppaux.rs b/src/comp/util/ppaux.rs
index 2bdb8742478..a598237284b 100644
--- a/src/comp/util/ppaux.rs
+++ b/src/comp/util/ppaux.rs
@@ -132,7 +132,7 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> str {
       }
       ty_var(v) { s += "<T" + int::str(v) + ">"; }
       ty_param(id,_) {
-        s += "'" + str::unsafe_from_bytes([('a' as u8) + (id as u8)]);
+        s += "'" + str::unsafe_from_bytes_ivec(~[('a' as u8) + (id as u8)]);
       }
       _ { s += ty_to_short_str(cx, typ); }
     }
diff --git a/src/lib/extfmt.rs b/src/lib/extfmt.rs
index 08e2f86a789..295ae7fe110 100644
--- a/src/lib/extfmt.rs
+++ b/src/lib/extfmt.rs
@@ -356,9 +356,9 @@ mod rt {
 
     // FIXME: This might be useful in str: but needs to be utf8 safe first
     fn str_init_elt(c: char, n_elts: uint) -> str {
-        let svec = vec::init_elt[u8](c as u8, n_elts);
+        let svec = ivec::from_vec(vec::init_elt[u8](c as u8, n_elts));
 
-        ret str::unsafe_from_bytes(svec);
+        ret str::unsafe_from_bytes_ivec((svec));
     }
     tag pad_mode { pad_signed; pad_unsigned; pad_nozero; }
     fn pad(cv: &conv, s: str, mode: pad_mode) -> str {
@@ -407,7 +407,7 @@ mod rt {
         if signed && zero_padding && str::byte_len(s) > 0u {
             let head = s.(0);
             if head == '+' as u8 || head == '-' as u8 || head == ' ' as u8 {
-                let headstr = str::unsafe_from_bytes([head]);
+                let headstr = str::unsafe_from_bytes_ivec(~[head]);
                 let bytelen = str::byte_len(s);
                 let numpart = str::substr(s, 1u, bytelen - 1u);
                 ret headstr + padstr + numpart;
diff --git a/src/lib/io.rs b/src/lib/io.rs
index 5aa490349d1..3407eba4875 100644
--- a/src/lib/io.rs
+++ b/src/lib/io.rs
@@ -120,7 +120,7 @@ obj new_reader(rdr: buf_reader) {
                 go_on = false;
             } else { vec::push[u8](buf, ch as u8); }
         }
-        ret str::unsafe_from_bytes(buf);
+        ret str::unsafe_from_bytes_ivec(ivec::from_vec(buf));
     }
     fn read_c_str() -> str {
         let buf: vec[u8] = [];
@@ -131,7 +131,7 @@ obj new_reader(rdr: buf_reader) {
                 go_on = false;
             } else { vec::push[u8](buf, ch as u8); }
         }
-        ret str::unsafe_from_bytes(buf);
+        ret str::unsafe_from_bytes_ivec(ivec::from_vec(buf));
     }
 
     // FIXME deal with eof?
@@ -440,7 +440,9 @@ fn string_writer() -> str_writer {
     let buf: mutable_byte_buf = @{mutable buf: b, mutable pos: 0u};
     obj str_writer_wrap(wr: writer, buf: mutable_byte_buf) {
         fn get_writer() -> writer { ret wr; }
-        fn get_str() -> str { ret str::unsafe_from_bytes(buf.buf); }
+        fn get_str() -> str {
+            ret str::unsafe_from_bytes_ivec(ivec::from_vec(buf.buf));
+        }
     }
     ret str_writer_wrap(new_writer(byte_buf_writer(buf)), buf);
 }
diff --git a/src/lib/ivec.rs b/src/lib/ivec.rs
index 8c77cbfe8d0..ab232f36c29 100644
--- a/src/lib/ivec.rs
+++ b/src/lib/ivec.rs
@@ -17,7 +17,7 @@ native "rust" mod rustrt {
                                     count: uint);
 }
 
-fn from_vec[@T](v: &vec[T]) -> [T] {
+fn from_vec[@T](v: &vec[mutable? T]) -> [T] {
     let iv = ~[];
     for e in v {
         iv += ~[e];
diff --git a/src/lib/run_program.rs b/src/lib/run_program.rs
index f2dd1280059..05e3ee3a1d9 100644
--- a/src/lib/run_program.rs
+++ b/src/lib/run_program.rs
@@ -103,8 +103,8 @@ fn start_program(prog: str, args: vec[str]) -> @program_res {
 fn read_all(rd: &io::reader) -> str {
     let buf = "";
     while !rd.eof() {
-        let bytes = rd.read_bytes(4096u);
-        buf += str::unsafe_from_bytes(bytes);
+        let bytes = ivec::from_vec(rd.read_bytes(4096u));
+        buf += str::unsafe_from_bytes_ivec(bytes);
     }
     ret buf;
 }
diff --git a/src/test/compiletest/procsrv.rs b/src/test/compiletest/procsrv.rs
index fa60a58ba64..d654091471f 100644
--- a/src/test/compiletest/procsrv.rs
+++ b/src/test/compiletest/procsrv.rs
@@ -87,8 +87,8 @@ fn readclose(fd: int) -> str {
     let reader = io::new_reader(io::FILE_buf_reader(file, option::none));
     let buf = "";
     while !reader.eof() {
-        let bytes = reader.read_bytes(4096u);
-        buf += str::unsafe_from_bytes(bytes);
+        let bytes = ivec::from_vec(reader.read_bytes(4096u));
+        buf += str::unsafe_from_bytes_ivec(bytes);
     }
     os::libc::fclose(file);
     ret buf;
diff --git a/src/test/stdtest/run.rs b/src/test/stdtest/run.rs
index 1be8cdf9b37..bc16e6ea2cf 100644
--- a/src/test/stdtest/run.rs
+++ b/src/test/stdtest/run.rs
@@ -4,6 +4,7 @@ import std::os;
 import std::io;
 import std::option;
 import std::str;
+import std::ivec;
 
 // Regression test for memory leaks
 #[cfg(target_os = "linux")]
@@ -58,8 +59,8 @@ fn test_pipes() {
         let reader = io::new_reader(io::FILE_buf_reader(file, option::none));
         let buf = "";
         while !reader.eof() {
-            let bytes = reader.read_bytes(4096u);
-            buf += str::unsafe_from_bytes(bytes);
+            let bytes = ivec::from_vec(reader.read_bytes(4096u));
+            buf += str::unsafe_from_bytes_ivec(bytes);
         }
         os::libc::fclose(file);
         ret buf;
diff --git a/src/test/stdtest/vec_str_conversions.rs b/src/test/stdtest/vec_str_conversions.rs
index 62a0ce79d6d..3b103f80e5c 100644
--- a/src/test/stdtest/vec_str_conversions.rs
+++ b/src/test/stdtest/vec_str_conversions.rs
@@ -3,24 +3,17 @@
 // -*- rust -*-
 use std;
 import std::str;
-import std::vec;
 import std::ivec;
 
 #[test]
 fn test_simple() {
     let s1: str = "All mimsy were the borogoves";
-    /*
-     * FIXME from_bytes(vec[u8] v) has constraint is_utf(v), which is
-     * unimplemented and thereby just fails.  This doesn't stop us from
-     * using from_bytes for now since the constraint system isn't fully
-     * working, but we should implement is_utf8 before that happens.
-     */
 
-    let v: vec[u8] = ivec::to_vec(str::bytes(s1));
-    let s2: str = str::unsafe_from_bytes(v);
+    let v: [u8] = str::bytes(s1);
+    let s2: str = str::unsafe_from_bytes_ivec(v);
     let i: uint = 0u;
     let n1: uint = str::byte_len(s1);
-    let n2: uint = vec::len[u8](v);
+    let n2: uint = ivec::len[u8](v);
     assert (n1 == n2);
     while i < n1 {
         let a: u8 = s1.(i);