Replacing str::unsafe_from_bytes with str::from_bytes (part 2)
This commit is contained in:
parent
c7b23f9a86
commit
64ce563c05
@ -85,7 +85,7 @@ fn readclose(fd: fd_t) -> str {
|
||||
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;
|
||||
@ -114,8 +114,8 @@ fn worker(p: port<request>) {
|
||||
// the alt discriminant are wrong.
|
||||
alt recv(p) {
|
||||
exec(lib_path, prog, args, respchan) {
|
||||
{lib_path: str::unsafe_from_bytes(lib_path),
|
||||
prog: str::unsafe_from_bytes(prog),
|
||||
{lib_path: str::from_bytes(lib_path),
|
||||
prog: str::from_bytes(prog),
|
||||
args: clone_vecu8str(args),
|
||||
respchan: respchan}
|
||||
}
|
||||
@ -189,7 +189,7 @@ fn clone_vecstr(v: [str]) -> [[u8]] {
|
||||
fn clone_vecu8str(v: [[u8]]) -> [str] {
|
||||
let r = [];
|
||||
for t in vec::slice(v, 0u, vec::len(v)) {
|
||||
r += [str::unsafe_from_bytes(t)];
|
||||
r += [str::from_bytes(t)];
|
||||
}
|
||||
ret r;
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ fn get_int_precision(cv: conv) -> uint {
|
||||
fn str_init_elt(n_elts: uint, c: char) -> str {
|
||||
let svec = vec::init_elt::<u8>(n_elts, c as u8);
|
||||
|
||||
ret str::unsafe_from_bytes(svec);
|
||||
ret str::from_bytes(svec);
|
||||
}
|
||||
enum pad_mode { pad_signed, pad_unsigned, pad_nozero, }
|
||||
fn pad(cv: conv, s: str, mode: pad_mode) -> str {
|
||||
@ -439,7 +439,7 @@ fn have_precision(cv: conv) -> bool {
|
||||
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::from_bytes([head]);
|
||||
// FIXME: not UTF-8 safe
|
||||
let bytelen = str::byte_len(s);
|
||||
let numpart = str::substr(s, 1u, bytelen - 1u);
|
||||
|
Loading…
Reference in New Issue
Block a user