"str": rename "str_from_cstr" to "from_cstr" (analogous to the other "from_*")
This commit is contained in:
parent
dd284eb396
commit
d1ffe5034b
@ -34,7 +34,7 @@ fn llvm_err(sess: session::session, msg: str) unsafe {
|
||||
let buf = llvm::LLVMRustGetLastError();
|
||||
if buf == ptr::null() {
|
||||
sess.fatal(msg);
|
||||
} else { sess.fatal(msg + ": " + str::str_from_cstr(buf)); }
|
||||
} else { sess.fatal(msg + ": " + str::from_cstr(buf)); }
|
||||
}
|
||||
|
||||
fn load_intrinsics_bc(sess: session::session) -> option::t<ModuleRef> {
|
||||
|
@ -216,7 +216,7 @@ fn get_metadata_section(sess: session::session,
|
||||
let si = mk_section_iter(of.llof);
|
||||
while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
|
||||
let name_buf = llvm::LLVMGetSectionName(si.llsi);
|
||||
let name = unsafe { str::str_from_cstr(name_buf) };
|
||||
let name = unsafe { str::from_cstr(name_buf) };
|
||||
if str::eq(name, sess.get_targ_cfg().target_strs.meta_sect_name) {
|
||||
let cbuf = llvm::LLVMGetSectionContents(si.llsi);
|
||||
let csz = llvm::LLVMGetSectionSize(si.llsi);
|
||||
|
@ -12,7 +12,7 @@ export eq, lteq, hash, is_empty, is_not_empty, is_whitespace, byte_len,
|
||||
push_char, is_utf8, from_chars, to_chars, char_len, char_len_range,
|
||||
char_at, bytes, is_ascii, shift_byte, pop_byte,
|
||||
unsafe_from_byte, unsafe_from_bytes, from_char, char_range_at,
|
||||
str_from_cstr, sbuf, as_buf, push_byte, utf8_char_width, safe_slice,
|
||||
from_cstr, sbuf, as_buf, push_byte, utf8_char_width, safe_slice,
|
||||
contains, iter_chars, loop_chars, loop_chars_sub,
|
||||
escape;
|
||||
|
||||
@ -973,11 +973,11 @@ fn as_buf<T>(s: str, f: block(sbuf) -> T) -> T unsafe {
|
||||
}
|
||||
|
||||
/*
|
||||
Function: str_from_cstr
|
||||
Function: from_cstr
|
||||
|
||||
Create a Rust string from a null-terminated C string
|
||||
*/
|
||||
unsafe fn str_from_cstr(cstr: sbuf) -> str {
|
||||
unsafe fn from_cstr(cstr: sbuf) -> str {
|
||||
let res = "";
|
||||
let start = cstr;
|
||||
let curr = start;
|
||||
|
@ -35,7 +35,7 @@ fn getenv(n: str) -> option::t<str> unsafe {
|
||||
option::none::<str>
|
||||
} else {
|
||||
let s = unsafe::reinterpret_cast(s);
|
||||
option::some::<str>(str::str_from_cstr(s))
|
||||
option::some::<str>(str::from_cstr(s))
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -287,10 +287,10 @@ fn unsafe_from_bytes() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn str_from_cstr() unsafe {
|
||||
fn from_cstr() unsafe {
|
||||
let a = [65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8];
|
||||
let b = vec::to_ptr(a);
|
||||
let c = str::str_from_cstr(b);
|
||||
let c = str::from_cstr(b);
|
||||
assert (c == "AAAAAAA");
|
||||
}
|
||||
|
||||
@ -312,7 +312,7 @@ fn as_buf_small() unsafe {
|
||||
fn as_buf2() unsafe {
|
||||
let s = "hello";
|
||||
let sb = str::as_buf(s, {|b| b });
|
||||
let s_cstr = str::str_from_cstr(sb);
|
||||
let s_cstr = str::from_cstr(sb);
|
||||
assert (str::eq(s_cstr, s));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user