Skip to content

Commit 9e48070

Browse files
committed
core:: Eliminate str::sbuf. Replace with *u8
1 parent 3864d6d commit 9e48070

File tree

6 files changed

+138
-145
lines changed

6 files changed

+138
-145
lines changed

src/libcore/os.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ export as_c_charp, fill_charp_buf;
3838
native mod rustrt {
3939
fn rust_env_pairs() -> [str];
4040
fn rust_getcwd() -> str;
41-
fn rust_path_is_dir(path: str::sbuf) -> c_int;
42-
fn rust_path_exists(path: str::sbuf) -> c_int;
41+
fn rust_path_is_dir(path: *u8) -> c_int;
42+
fn rust_path_exists(path: *u8) -> c_int;
4343
fn rust_list_files(path: str) -> [str];
4444
fn rust_process_wait(handle: c_int) -> c_int;
4545
}
@@ -66,7 +66,7 @@ fn fill_charp_buf(f: fn(*mutable c_char, size_t) -> bool)
6666
let buf = vec::to_mut(vec::from_elem(tmpbuf_sz, 0u8 as c_char));
6767
vec::as_mut_buf(buf) { |b|
6868
if f(b, tmpbuf_sz as size_t) {
69-
some(str::from_cstr(b as str::sbuf))
69+
some(str::from_cstr(b as *u8))
7070
} else {
7171
none
7272
}

src/libcore/run.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#[doc ="Process spawning"];
22
import option::{some, none};
3-
import str::sbuf;
43
import libc::{pid_t, c_void, c_int};
54

65
export program;
@@ -12,7 +11,7 @@ export waitpid;
1211

1312
#[abi = "cdecl"]
1413
native mod rustrt {
15-
fn rust_run_program(argv: *sbuf, envp: *c_void, dir: sbuf,
14+
fn rust_run_program(argv: **u8, envp: *c_void, dir: *u8,
1615
in_fd: c_int, out_fd: c_int, err_fd: c_int)
1716
-> pid_t;
1817
}
@@ -78,7 +77,7 @@ fn spawn_process(prog: str, args: [str],
7877
}
7978

8079
fn with_argv<T>(prog: str, args: [str],
81-
cb: fn(*sbuf) -> T) -> T unsafe {
80+
cb: fn(**u8) -> T) -> T unsafe {
8281
let mut argptrs = str::as_buf(prog) {|b| [b] };
8382
let mut tmps = [];
8483
for arg in args {
@@ -141,7 +140,7 @@ fn with_envp<T>(env: option<[(str,str)]>,
141140
}
142141

143142
fn with_dirp<T>(d: option<str>,
144-
cb: fn(sbuf) -> T) -> T unsafe {
143+
cb: fn(*u8) -> T) -> T unsafe {
145144
alt d {
146145
some(dir) { str::as_buf(dir, cb) }
147146
none { cb(ptr::null()) }

src/libcore/str.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ export
9090
char_at,
9191
as_bytes,
9292
as_buf,
93-
sbuf,
9493
reserve,
9594

9695
unsafe;
@@ -184,7 +183,7 @@ fn from_chars(chs: [char]) -> str {
184183
}
185184

186185
#[doc = "Create a Rust string from a null-terminated C string"]
187-
fn from_cstr(cstr: sbuf) -> str unsafe {
186+
fn from_cstr(cstr: *u8) -> str unsafe {
188187
let mut curr = cstr, i = 0u;
189188
while *curr != 0u8 {
190189
i += 1u;
@@ -194,7 +193,7 @@ fn from_cstr(cstr: sbuf) -> str unsafe {
194193
}
195194

196195
#[doc = "Create a Rust string from a C string of the given length"]
197-
fn from_cstr_len(cstr: sbuf, len: uint) -> str unsafe {
196+
fn from_cstr_len(cstr: *u8, len: uint) -> str unsafe {
198197
let mut buf: [u8] = [];
199198
vec::reserve(buf, len + 1u);
200199
vec::as_buf(buf) {|b| ptr::memcpy(b, cstr, len); }
@@ -1248,13 +1247,10 @@ interop.
12481247
let s = str::as_buf(\"PATH\", { |path_buf| libc::getenv(path_buf) });
12491248
```
12501249
"]
1251-
fn as_buf<T>(s: str, f: fn(sbuf) -> T) -> T unsafe {
1250+
fn as_buf<T>(s: str, f: fn(*u8) -> T) -> T unsafe {
12521251
as_bytes(s) { |v| vec::as_buf(v, f) }
12531252
}
12541253

1255-
#[doc = "An unsafe buffer of bytes"]
1256-
type sbuf = *u8;
1257-
12581254
#[doc = "Allocate more memory for a string, up to `nn` + 1 bytes"]
12591255
fn reserve(&ss: str, nn: uint) {
12601256
rustrt::str_reserve_shared(ss, nn);

0 commit comments

Comments
 (0)