aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2011-03-16 18:40:51 -0700
committerPatrick Walton <[email protected]>2011-03-16 18:42:08 -0700
commitea7197e2cf921211fb3b82ad45452c2095f5a589 (patch)
tree7023e317dcc61a637388a42b746d91079413eed2 /src/lib
parentTeach configure.sh to probe paths, factor a bit. (diff)
downloadrust-ea7197e2cf921211fb3b82ad45452c2095f5a589.tar.xz
rust-ea7197e2cf921211fb3b82ad45452c2095f5a589.zip
rustc: Add str_from_cstr() and str_from_buf() functions to the standard library, as well as a test case
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/_str.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/_str.rs b/src/lib/_str.rs
index db9413b9..93d0a9f2 100644
--- a/src/lib/_str.rs
+++ b/src/lib/_str.rs
@@ -8,6 +8,8 @@ native "rust" mod rustrt {
fn str_byte_len(str s) -> uint;
fn str_alloc(uint n_bytes) -> str;
fn str_from_vec(vec[u8] b) -> str;
+ fn str_from_cstr(sbuf cstr) -> str;
+ fn str_from_buf(sbuf buf, uint len) -> str;
fn refcount[T](str s) -> uint;
}
@@ -115,6 +117,14 @@ fn unsafe_from_byte(u8 u) -> str {
ret rustrt.str_from_vec(vec(u));
}
+unsafe fn str_from_cstr(sbuf cstr) -> str {
+ ret rustrt.str_from_cstr(cstr);
+}
+
+unsafe fn str_from_buf(sbuf buf, uint len) -> str {
+ ret rustrt.str_from_buf(buf, len);
+}
+
fn refcount(str s) -> uint {
auto r = rustrt.refcount[u8](s);