Finally rename std::_xxx to std::xxx
Except for _task, which is still a keyword.
This commit is contained in:
parent
6067050656
commit
09d8ef8d51
87 changed files with 1224 additions and 1224 deletions
|
|
@ -21,19 +21,19 @@ fn create(uint nbits, bool init) -> t {
|
|||
elt = 0u;
|
||||
}
|
||||
|
||||
auto storage = _vec::init_elt_mut[uint](elt, nbits / uint_bits() + 1u);
|
||||
auto storage = vec::init_elt_mut[uint](elt, nbits / uint_bits() + 1u);
|
||||
ret rec(storage = storage, nbits = nbits);
|
||||
}
|
||||
|
||||
fn process(&fn(uint, uint) -> uint op, &t v0, &t v1) -> bool {
|
||||
auto len = _vec::len(v1.storage);
|
||||
auto len = vec::len(v1.storage);
|
||||
|
||||
assert (_vec::len(v0.storage) == len);
|
||||
assert (vec::len(v0.storage) == len);
|
||||
assert (v0.nbits == v1.nbits);
|
||||
|
||||
auto changed = false;
|
||||
|
||||
for each (uint i in _uint::range(0u, len)) {
|
||||
for each (uint i in uint::range(0u, len)) {
|
||||
auto w0 = v0.storage.(i);
|
||||
auto w1 = v1.storage.(i);
|
||||
|
||||
|
|
@ -75,9 +75,9 @@ fn copy(&t v0, t v1) -> bool {
|
|||
}
|
||||
|
||||
fn clone(t v) -> t {
|
||||
auto storage = _vec::init_elt_mut[uint](0u, v.nbits / uint_bits() + 1u);
|
||||
auto len = _vec::len(v.storage);
|
||||
for each (uint i in _uint::range(0u, len)) {
|
||||
auto storage = vec::init_elt_mut[uint](0u, v.nbits / uint_bits() + 1u);
|
||||
auto len = vec::len(v.storage);
|
||||
for each (uint i in uint::range(0u, len)) {
|
||||
storage.(i) = v.storage.(i);
|
||||
}
|
||||
ret rec(storage = storage, nbits = v.nbits);
|
||||
|
|
@ -97,7 +97,7 @@ fn get(&t v, uint i) -> bool {
|
|||
fn equal(&t v0, &t v1) -> bool {
|
||||
// FIXME: when we can break or return from inside an iterator loop,
|
||||
// we can eliminate this painful while-loop
|
||||
auto len = _vec::len(v1.storage);
|
||||
auto len = vec::len(v1.storage);
|
||||
auto i = 0u;
|
||||
while (i < len) {
|
||||
if (v0.storage.(i) != v1.storage.(i)) {
|
||||
|
|
@ -109,13 +109,13 @@ fn equal(&t v0, &t v1) -> bool {
|
|||
}
|
||||
|
||||
fn clear(&t v) {
|
||||
for each (uint i in _uint::range(0u, _vec::len(v.storage))) {
|
||||
for each (uint i in uint::range(0u, vec::len(v.storage))) {
|
||||
v.storage.(i) = 0u;
|
||||
}
|
||||
}
|
||||
|
||||
fn invert(&t v) {
|
||||
for each (uint i in _uint::range(0u, _vec::len(v.storage))) {
|
||||
for each (uint i in uint::range(0u, vec::len(v.storage))) {
|
||||
v.storage.(i) = ~v.storage.(i);
|
||||
}
|
||||
}
|
||||
|
|
@ -176,7 +176,7 @@ fn init_to_vec(t v, uint i) -> uint {
|
|||
|
||||
fn to_vec(&t v) -> vec[uint] {
|
||||
auto sub = bind init_to_vec(v, _);
|
||||
ret _vec::init_fn[uint](sub, v.nbits);
|
||||
ret vec::init_fn[uint](sub, v.nbits);
|
||||
}
|
||||
|
||||
fn to_str(&t v) -> str {
|
||||
|
|
@ -196,7 +196,7 @@ fn to_str(&t v) -> str {
|
|||
|
||||
// FIXME: can we just use structural equality on to_vec?
|
||||
fn eq_vec(&t v0, &vec[uint] v1) -> bool {
|
||||
assert (v0.nbits == _vec::len[uint](v1));
|
||||
assert (v0.nbits == vec::len[uint](v1));
|
||||
auto len = v0.nbits;
|
||||
auto i = 0u;
|
||||
while (i < len) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ native "rust" mod rustrt {
|
|||
}
|
||||
|
||||
fn debug_vec[T](vec[T] v) {
|
||||
_vec::print_debug_info[T](v);
|
||||
vec::print_debug_info[T](v);
|
||||
}
|
||||
|
||||
fn debug_tydesc[T]() {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ fn create[T]() -> t[T] {
|
|||
* elsewhere.
|
||||
*/
|
||||
fn grow[T](uint nelts, uint lo, vec[cell[T]] elts) -> vec[cell[T]] {
|
||||
assert (nelts == _vec::len[cell[T]](elts));
|
||||
assert (nelts == vec::len[cell[T]](elts));
|
||||
|
||||
fn fill[T](uint i, uint nelts, uint lo,
|
||||
vec[cell[T]] old) -> cell[T] {
|
||||
|
|
@ -39,9 +39,9 @@ fn create[T]() -> t[T] {
|
|||
}
|
||||
}
|
||||
|
||||
let uint nalloc = _uint::next_power_of_two(nelts + 1u);
|
||||
let _vec::init_op[cell[T]] copy_op = bind fill[T](_, nelts, lo, elts);
|
||||
ret _vec::init_fn[cell[T]](copy_op, nalloc);
|
||||
let uint nalloc = uint::next_power_of_two(nelts + 1u);
|
||||
let vec::init_op[cell[T]] copy_op = bind fill[T](_, nelts, lo, elts);
|
||||
ret vec::init_fn[cell[T]](copy_op, nalloc);
|
||||
}
|
||||
|
||||
fn get[T](vec[cell[T]] elts, uint i) -> T {
|
||||
|
|
@ -63,14 +63,14 @@ fn create[T]() -> t[T] {
|
|||
let uint oldlo = lo;
|
||||
|
||||
if (lo == 0u) {
|
||||
lo = _vec::len[cell[T]](elts) - 1u;
|
||||
lo = vec::len[cell[T]](elts) - 1u;
|
||||
} else {
|
||||
lo -= 1u;
|
||||
}
|
||||
|
||||
if (lo == hi) {
|
||||
elts = grow[T](nelts, oldlo, elts);
|
||||
lo = _vec::len[cell[T]](elts) - 1u;
|
||||
lo = vec::len[cell[T]](elts) - 1u;
|
||||
hi = nelts;
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ fn create[T]() -> t[T] {
|
|||
}
|
||||
|
||||
elts.(hi) = option::some[T](t);
|
||||
hi = (hi + 1u) % _vec::len[cell[T]](elts);
|
||||
hi = (hi + 1u) % vec::len[cell[T]](elts);
|
||||
nelts += 1u;
|
||||
}
|
||||
|
||||
|
|
@ -97,14 +97,14 @@ fn create[T]() -> t[T] {
|
|||
fn pop_front() -> T {
|
||||
let T t = get[T](elts, lo);
|
||||
elts.(lo) = option::none[T];
|
||||
lo = (lo + 1u) % _vec::len[cell[T]](elts);
|
||||
lo = (lo + 1u) % vec::len[cell[T]](elts);
|
||||
nelts -= 1u;
|
||||
ret t;
|
||||
}
|
||||
|
||||
fn pop_back() -> T {
|
||||
if (hi == 0u) {
|
||||
hi = _vec::len[cell[T]](elts) - 1u;
|
||||
hi = vec::len[cell[T]](elts) - 1u;
|
||||
} else {
|
||||
hi -= 1u;
|
||||
}
|
||||
|
|
@ -124,12 +124,12 @@ fn create[T]() -> t[T] {
|
|||
}
|
||||
|
||||
fn get(int i) -> T {
|
||||
let uint idx = (lo + (i as uint)) % _vec::len[cell[T]](elts);
|
||||
let uint idx = (lo + (i as uint)) % vec::len[cell[T]](elts);
|
||||
ret get[T](elts, idx);
|
||||
}
|
||||
|
||||
}
|
||||
let vec[cell[T]] v = _vec::init_elt[cell[T]](option::none[T],
|
||||
let vec[cell[T]] v = vec::init_elt[cell[T]](option::none[T],
|
||||
initial_capacity);
|
||||
|
||||
ret deque[T](0u, 0u, 0u, v);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ fn vint_at(vec[u8] data, uint start) -> tup(uint, uint) {
|
|||
}
|
||||
|
||||
fn new_doc(vec[u8] data) -> doc {
|
||||
ret rec(data=data, start=0u, end=_vec::len[u8](data));
|
||||
ret rec(data=data, start=0u, end=vec::len[u8](data));
|
||||
}
|
||||
|
||||
fn doc_at(vec[u8] data, uint start) -> doc {
|
||||
|
|
@ -65,7 +65,7 @@ fn get_doc(doc d, uint tg) -> doc {
|
|||
alt (maybe_get_doc(d, tg)) {
|
||||
case (some[doc](?d)) {ret d;}
|
||||
case (none[doc]) {
|
||||
log_err "failed to find block with tag " + _uint::to_str(tg, 10u);
|
||||
log_err "failed to find block with tag " + uint::to_str(tg, 10u);
|
||||
fail;
|
||||
}
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ iter tagged_docs(doc d, uint tg) -> doc {
|
|||
}
|
||||
|
||||
fn doc_data(doc d) -> vec[u8] {
|
||||
ret _vec::slice[u8](d.data, d.start, d.end);
|
||||
ret vec::slice[u8](d.data, d.start, d.end);
|
||||
}
|
||||
|
||||
fn be_uint_from_bytes(vec[u8] data, uint start, uint size) -> uint {
|
||||
|
|
@ -175,7 +175,7 @@ fn start_tag(&writer w, uint tag_id) {
|
|||
}
|
||||
|
||||
fn end_tag(&writer w) {
|
||||
auto last_size_pos = _vec::pop[uint](w.size_positions);
|
||||
auto last_size_pos = vec::pop[uint](w.size_positions);
|
||||
auto cur_pos = w.writer.tell();
|
||||
w.writer.seek(last_size_pos as int, io::seek_set);
|
||||
write_sized_vint(w.writer, cur_pos - last_size_pos - 4u, 4u);
|
||||
|
|
|
|||
|
|
@ -80,11 +80,11 @@ mod ct {
|
|||
|
||||
fn parse_fmt_string(str s) -> vec[piece] {
|
||||
let vec[piece] pieces = [];
|
||||
auto lim = _str::byte_len(s);
|
||||
auto lim = str::byte_len(s);
|
||||
auto buf = "";
|
||||
|
||||
fn flush_buf(str buf, &vec[piece] pieces) -> str {
|
||||
if (_str::byte_len(buf) > 0u) {
|
||||
if (str::byte_len(buf) > 0u) {
|
||||
auto piece = piece_string(buf);
|
||||
pieces += [piece];
|
||||
}
|
||||
|
|
@ -93,15 +93,15 @@ mod ct {
|
|||
|
||||
auto i = 0u;
|
||||
while (i < lim) {
|
||||
auto curr = _str::substr(s, i, 1u);
|
||||
if (_str::eq(curr, "%")) {
|
||||
auto curr = str::substr(s, i, 1u);
|
||||
if (str::eq(curr, "%")) {
|
||||
i += 1u;
|
||||
if (i >= lim) {
|
||||
log_err "unterminated conversion at end of string";
|
||||
fail;
|
||||
}
|
||||
auto curr2 = _str::substr(s, i, 1u);
|
||||
if (_str::eq(curr2, "%")) {
|
||||
auto curr2 = str::substr(s, i, 1u);
|
||||
if (str::eq(curr2, "%")) {
|
||||
i += 1u;
|
||||
} else {
|
||||
buf = flush_buf(buf, pieces);
|
||||
|
|
@ -270,27 +270,27 @@ mod ct {
|
|||
}
|
||||
|
||||
auto t;
|
||||
auto tstr = _str::substr(s, i, 1u);
|
||||
if (_str::eq(tstr, "b")) {
|
||||
auto tstr = str::substr(s, i, 1u);
|
||||
if (str::eq(tstr, "b")) {
|
||||
t = ty_bool;
|
||||
} else if (_str::eq(tstr, "s")) {
|
||||
} else if (str::eq(tstr, "s")) {
|
||||
t = ty_str;
|
||||
} else if (_str::eq(tstr, "c")) {
|
||||
} else if (str::eq(tstr, "c")) {
|
||||
t = ty_char;
|
||||
} else if (_str::eq(tstr, "d")
|
||||
|| _str::eq(tstr, "i")) {
|
||||
} else if (str::eq(tstr, "d")
|
||||
|| str::eq(tstr, "i")) {
|
||||
// TODO: Do we really want two signed types here?
|
||||
// How important is it to be printf compatible?
|
||||
t = ty_int(signed);
|
||||
} else if (_str::eq(tstr, "u")) {
|
||||
} else if (str::eq(tstr, "u")) {
|
||||
t = ty_int(unsigned);
|
||||
} else if (_str::eq(tstr, "x")) {
|
||||
} else if (str::eq(tstr, "x")) {
|
||||
t = ty_hex(case_lower);
|
||||
} else if (_str::eq(tstr, "X")) {
|
||||
} else if (str::eq(tstr, "X")) {
|
||||
t = ty_hex(case_upper);
|
||||
} else if (_str::eq(tstr, "t")) {
|
||||
} else if (str::eq(tstr, "t")) {
|
||||
t = ty_bits;
|
||||
} else if (_str::eq(tstr, "o")) {
|
||||
} else if (str::eq(tstr, "o")) {
|
||||
t = ty_octal;
|
||||
} else {
|
||||
log_err "unknown type in conversion";
|
||||
|
|
@ -364,7 +364,7 @@ mod rt {
|
|||
res = uint_to_str_prec(u, 16u, prec);
|
||||
}
|
||||
case (ty_hex_upper) {
|
||||
res = _str::to_upper(uint_to_str_prec(u, 16u, prec));
|
||||
res = str::to_upper(uint_to_str_prec(u, 16u, prec));
|
||||
}
|
||||
case (ty_bits) {
|
||||
res = uint_to_str_prec(u, 2u, prec);
|
||||
|
|
@ -389,7 +389,7 @@ mod rt {
|
|||
}
|
||||
|
||||
fn conv_char(&conv cv, char c) -> str {
|
||||
ret pad(cv, _str::from_char(c), pad_nozero);
|
||||
ret pad(cv, str::from_char(c), pad_nozero);
|
||||
}
|
||||
|
||||
fn conv_str(&conv cv, str s) -> str {
|
||||
|
|
@ -399,9 +399,9 @@ mod rt {
|
|||
}
|
||||
case (count_is(?max)) {
|
||||
// For strings, precision is the maximum characters displayed
|
||||
if (max as uint < _str::char_len(s)) {
|
||||
if (max as uint < str::char_len(s)) {
|
||||
// FIXME: substr works on bytes, not chars!
|
||||
unpadded = _str::substr(s, 0u, max as uint);
|
||||
unpadded = str::substr(s, 0u, max as uint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -420,15 +420,15 @@ mod rt {
|
|||
|
||||
// Convert a uint to string with a minimum number of digits. If precision
|
||||
// is 0 and num is 0 then the result is the empty string. Could move this
|
||||
// to _uint: but it doesn't seem all that useful.
|
||||
// to uint: but it doesn't seem all that useful.
|
||||
fn uint_to_str_prec(uint num, uint radix, uint prec) -> str {
|
||||
auto s;
|
||||
|
||||
if (prec == 0u && num == 0u) {
|
||||
s = "";
|
||||
} else {
|
||||
s = _uint::to_str(num, radix);
|
||||
auto len = _str::char_len(s);
|
||||
s = uint::to_str(num, radix);
|
||||
auto len = str::char_len(s);
|
||||
if (len < prec) {
|
||||
auto diff = prec - len;
|
||||
auto pad = str_init_elt('0', diff);
|
||||
|
|
@ -450,12 +450,12 @@ mod rt {
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: This might be useful in _str: but needs to be utf8 safe first
|
||||
// FIXME: This might be useful in str: but needs to be utf8 safe first
|
||||
fn str_init_elt(char c, uint n_elts) -> str {
|
||||
auto svec = _vec::init_elt[u8](c as u8, n_elts);
|
||||
auto svec = vec::init_elt[u8](c as u8, n_elts);
|
||||
// FIXME: Using unsafe_from_bytes because rustboot
|
||||
// can't figure out the is_utf8 predicate on from_bytes?
|
||||
ret _str::unsafe_from_bytes(svec);
|
||||
ret str::unsafe_from_bytes(svec);
|
||||
}
|
||||
|
||||
tag pad_mode {
|
||||
|
|
@ -476,7 +476,7 @@ mod rt {
|
|||
}
|
||||
}
|
||||
|
||||
auto strlen = _str::char_len(s);
|
||||
auto strlen = str::char_len(s);
|
||||
if (uwidth <= strlen) {
|
||||
ret s;
|
||||
}
|
||||
|
|
@ -532,16 +532,16 @@ mod rt {
|
|||
// instead.
|
||||
if (signed
|
||||
&& zero_padding
|
||||
&& _str::byte_len(s) > 0u) {
|
||||
&& str::byte_len(s) > 0u) {
|
||||
|
||||
auto head = s.(0);
|
||||
if (head == '+' as u8
|
||||
|| head == '-' as u8
|
||||
|| head == ' ' as u8) {
|
||||
|
||||
auto headstr = _str::unsafe_from_bytes([head]);
|
||||
auto bytelen = _str::byte_len(s);
|
||||
auto numpart = _str::substr(s, 1u, bytelen - 1u);
|
||||
auto headstr = str::unsafe_from_bytes([head]);
|
||||
auto bytelen = str::byte_len(s);
|
||||
auto numpart = str::substr(s, 1u, bytelen - 1u);
|
||||
ret headstr + padstr + numpart;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,24 +3,24 @@ native "rust" mod rustrt {
|
|||
}
|
||||
|
||||
fn path_sep() -> str {
|
||||
ret _str::from_char(os_fs::path_sep);
|
||||
ret str::from_char(os_fs::path_sep);
|
||||
}
|
||||
|
||||
type path = str;
|
||||
|
||||
fn dirname(path p) -> path {
|
||||
let int i = _str::rindex(p, os_fs::path_sep as u8);
|
||||
let int i = str::rindex(p, os_fs::path_sep as u8);
|
||||
if (i == -1) {
|
||||
i = _str::rindex(p, os_fs::alt_path_sep as u8);
|
||||
i = str::rindex(p, os_fs::alt_path_sep as u8);
|
||||
if (i == -1) {
|
||||
ret p;
|
||||
}
|
||||
}
|
||||
ret _str::substr(p, 0u, i as uint);
|
||||
ret str::substr(p, 0u, i as uint);
|
||||
}
|
||||
|
||||
fn connect(path pre, path post) -> path {
|
||||
auto len = _str::byte_len(pre);
|
||||
auto len = str::byte_len(pre);
|
||||
if (pre.(len - 1u) == (os_fs::path_sep as u8)) { // Trailing '/'?
|
||||
ret pre + post;
|
||||
}
|
||||
|
|
@ -32,14 +32,14 @@ fn file_is_dir(path p) -> bool {
|
|||
}
|
||||
|
||||
fn list_dir(path p) -> vec[str] {
|
||||
auto pl = _str::byte_len(p);
|
||||
auto pl = str::byte_len(p);
|
||||
if (pl == 0u || p.(pl - 1u) as char != os_fs::path_sep) {
|
||||
p += path_sep();
|
||||
}
|
||||
let vec[str] full_paths = [];
|
||||
for (str filename in os_fs::list_dir(p)) {
|
||||
if (!_str::eq(filename, ".")) {if (!_str::eq(filename, "..")) {
|
||||
_vec::push[str](full_paths, p + filename);
|
||||
if (!str::eq(filename, ".")) {if (!str::eq(filename, "..")) {
|
||||
vec::push[str](full_paths, p + filename);
|
||||
}}
|
||||
}
|
||||
ret full_paths;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
fn getenv(str n) -> option::t[str] {
|
||||
auto s = os::libc::getenv(_str::buf(n));
|
||||
auto s = os::libc::getenv(str::buf(n));
|
||||
if ((s as int) == 0) {
|
||||
ret option::none[str];
|
||||
} else {
|
||||
ret option::some[str](_str::str_from_cstr(s));
|
||||
ret option::some[str](str::str_from_cstr(s));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ tag occur { req; optional; multi; }
|
|||
type opt = rec(name name, hasarg hasarg, occur occur);
|
||||
|
||||
fn mkname(str nm) -> name {
|
||||
if (_str::char_len(nm) == 1u) { ret short(_str::char_at(nm, 0u)); }
|
||||
if (str::char_len(nm) == 1u) { ret short(str::char_at(nm, 0u)); }
|
||||
else { ret long(nm); }
|
||||
}
|
||||
fn reqopt(str name) -> opt {
|
||||
|
|
@ -41,11 +41,11 @@ tag optval {
|
|||
type match = rec(vec[opt] opts, vec[mutable vec[optval]] vals, vec[str] free);
|
||||
|
||||
fn is_arg(str arg) -> bool {
|
||||
ret _str::byte_len(arg) > 1u && arg.(0) == '-' as u8;
|
||||
ret str::byte_len(arg) > 1u && arg.(0) == '-' as u8;
|
||||
}
|
||||
fn name_str(name nm) -> str {
|
||||
alt (nm) {
|
||||
case (short(?ch)) {ret _str::from_char(ch);}
|
||||
case (short(?ch)) {ret str::from_char(ch);}
|
||||
case (long(?s)) {ret s;}
|
||||
}
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ fn name_eq(name a, name b) -> bool {
|
|||
alt (a) {
|
||||
case (long(?a)) {
|
||||
alt (b) {
|
||||
case (long(?b)) { ret _str::eq(a, b); }
|
||||
case (long(?b)) { ret str::eq(a, b); }
|
||||
case (_) { ret false; }
|
||||
}
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ fn name_eq(name a, name b) -> bool {
|
|||
}
|
||||
fn find_opt(vec[opt] opts, name nm) -> option::t[uint] {
|
||||
auto i = 0u;
|
||||
auto l = _vec::len[opt](opts);
|
||||
auto l = vec::len[opt](opts);
|
||||
while (i < l) {
|
||||
if (name_eq(opts.(i).name, nm)) { ret some[uint](i); }
|
||||
i += 1u;
|
||||
|
|
@ -102,41 +102,41 @@ tag result {
|
|||
}
|
||||
|
||||
fn getopts(vec[str] args, vec[opt] opts) -> result {
|
||||
auto n_opts = _vec::len[opt](opts);
|
||||
fn empty_(uint x) -> vec[optval]{ret _vec::empty[optval]();}
|
||||
auto n_opts = vec::len[opt](opts);
|
||||
fn empty_(uint x) -> vec[optval]{ret vec::empty[optval]();}
|
||||
auto f = empty_;
|
||||
auto vals = _vec::init_fn_mut[vec[optval]](f, n_opts);
|
||||
auto vals = vec::init_fn_mut[vec[optval]](f, n_opts);
|
||||
let vec[str] free = [];
|
||||
|
||||
auto l = _vec::len[str](args);
|
||||
auto l = vec::len[str](args);
|
||||
auto i = 0u;
|
||||
while (i < l) {
|
||||
auto cur = args.(i);
|
||||
auto curlen = _str::byte_len(cur);
|
||||
auto curlen = str::byte_len(cur);
|
||||
if (!is_arg(cur)) {
|
||||
_vec::push[str](free, cur);
|
||||
} else if (_str::eq(cur, "--")) {
|
||||
free += _vec::slice[str](args, i + 1u, l);
|
||||
vec::push[str](free, cur);
|
||||
} else if (str::eq(cur, "--")) {
|
||||
free += vec::slice[str](args, i + 1u, l);
|
||||
break;
|
||||
} else {
|
||||
auto names;
|
||||
auto i_arg = option::none[str];
|
||||
if (cur.(1) == '-' as u8) {
|
||||
auto tail = _str::slice(cur, 2u, curlen);
|
||||
auto eq = _str::index(tail, '=' as u8);
|
||||
auto tail = str::slice(cur, 2u, curlen);
|
||||
auto eq = str::index(tail, '=' as u8);
|
||||
if (eq == -1) {
|
||||
names = [long(tail)];
|
||||
} else {
|
||||
names = [long(_str::slice(tail, 0u, eq as uint))];
|
||||
names = [long(str::slice(tail, 0u, eq as uint))];
|
||||
i_arg = option::some[str]
|
||||
(_str::slice(tail, (eq as uint) + 1u, curlen - 2u));
|
||||
(str::slice(tail, (eq as uint) + 1u, curlen - 2u));
|
||||
}
|
||||
} else {
|
||||
auto j = 1u;
|
||||
names = [];
|
||||
while (j < curlen) {
|
||||
auto range = _str::char_range_at(cur, j);
|
||||
_vec::push[name](names, short(range._0));
|
||||
auto range = str::char_range_at(cur, j);
|
||||
vec::push[name](names, short(range._0));
|
||||
j = range._1;
|
||||
}
|
||||
}
|
||||
|
|
@ -152,29 +152,29 @@ fn getopts(vec[str] args, vec[opt] opts) -> result {
|
|||
}
|
||||
alt (opts.(optid).hasarg) {
|
||||
case (no) {
|
||||
_vec::push[optval](vals.(optid), given);
|
||||
vec::push[optval](vals.(optid), given);
|
||||
}
|
||||
case (maybe) {
|
||||
if (!option::is_none[str](i_arg)) {
|
||||
_vec::push[optval](vals.(optid),
|
||||
vec::push[optval](vals.(optid),
|
||||
val(option::get[str](i_arg)));
|
||||
} else if (name_pos < _vec::len[name](names) ||
|
||||
} else if (name_pos < vec::len[name](names) ||
|
||||
i + 1u == l || is_arg(args.(i + 1u))) {
|
||||
_vec::push[optval](vals.(optid), given);
|
||||
vec::push[optval](vals.(optid), given);
|
||||
} else {
|
||||
i += 1u;
|
||||
_vec::push[optval](vals.(optid), val(args.(i)));
|
||||
vec::push[optval](vals.(optid), val(args.(i)));
|
||||
}
|
||||
}
|
||||
case (yes) {
|
||||
if (!option::is_none[str](i_arg)) {
|
||||
_vec::push[optval](vals.(optid),
|
||||
vec::push[optval](vals.(optid),
|
||||
val(option::get[str](i_arg)));
|
||||
} else if (i + 1u == l) {
|
||||
ret failure(argument_missing(name_str(nm)));
|
||||
} else {
|
||||
i += 1u;
|
||||
_vec::push[optval](vals.(optid), val(args.(i)));
|
||||
vec::push[optval](vals.(optid), val(args.(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -185,7 +185,7 @@ fn getopts(vec[str] args, vec[opt] opts) -> result {
|
|||
|
||||
i = 0u;
|
||||
while (i < n_opts) {
|
||||
auto n = _vec::len[optval](vals.(i));
|
||||
auto n = vec::len[optval](vals.(i));
|
||||
auto occ = opts.(i).occur;
|
||||
if (occ == req) {if (n == 0u) {
|
||||
ret failure(option_missing(name_str(opts.(i).name)));
|
||||
|
|
@ -212,7 +212,7 @@ fn opt_val(match m, str nm) -> optval {
|
|||
ret opt_vals(m, nm).(0);
|
||||
}
|
||||
fn opt_present(match m, str nm) -> bool {
|
||||
ret _vec::len[optval](opt_vals(m, nm)) > 0u;
|
||||
ret vec::len[optval](opt_vals(m, nm)) > 0u;
|
||||
}
|
||||
fn opt_str(match m, str nm) -> str {
|
||||
alt (opt_val(m, nm)) {
|
||||
|
|
@ -224,7 +224,7 @@ fn opt_strs(match m, str nm) -> vec[str] {
|
|||
let vec[str] acc = [];
|
||||
for (optval v in opt_vals(m, nm)) {
|
||||
alt (v) {
|
||||
case (val(?s)) { _vec::push[str](acc, s); }
|
||||
case (val(?s)) { vec::push[str](acc, s); }
|
||||
case (_) {}
|
||||
}
|
||||
}
|
||||
|
|
@ -232,7 +232,7 @@ fn opt_strs(match m, str nm) -> vec[str] {
|
|||
}
|
||||
fn opt_maybe_str(match m, str nm) -> option::t[str] {
|
||||
auto vals = opt_vals(m, nm);
|
||||
if (_vec::len[optval](vals) == 0u) { ret none[str]; }
|
||||
if (vec::len[optval](vals) == 0u) { ret none[str]; }
|
||||
alt (vals.(0)) {
|
||||
case (val(?s)) { ret some[str](s); }
|
||||
case (_) { ret none[str]; }
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ fn to_str(int n, uint radix) -> str
|
|||
{
|
||||
assert (0u < radix && radix <= 16u);
|
||||
if (n < 0) {
|
||||
ret "-" + _uint::to_str((-n) as uint, radix);
|
||||
ret "-" + uint::to_str((-n) as uint, radix);
|
||||
} else {
|
||||
ret _uint::to_str(n as uint, radix);
|
||||
ret uint::to_str(n as uint, radix);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -57,9 +57,9 @@ fn convert_whence(seek_style whence) -> int {
|
|||
|
||||
state obj FILE_buf_reader(os::libc::FILE f, bool must_close) {
|
||||
fn read(uint len) -> vec[u8] {
|
||||
auto buf = _vec::alloc[u8](len);
|
||||
auto read = os::libc::fread(_vec::buf[u8](buf), 1u, len, f);
|
||||
_vec::len_set[u8](buf, read);
|
||||
auto buf = vec::alloc[u8](len);
|
||||
auto read = os::libc::fread(vec::buf[u8](buf), 1u, len, f);
|
||||
vec::len_set[u8](buf, read);
|
||||
ret buf;
|
||||
}
|
||||
fn read_byte() -> int {
|
||||
|
|
@ -100,7 +100,7 @@ state obj new_reader(buf_reader rdr) {
|
|||
auto c0 = rdr.read_byte();
|
||||
if (c0 == -1) {ret -1 as char;} // FIXME will this stay valid?
|
||||
auto b0 = c0 as u8;
|
||||
auto w = _str::utf8_char_width(b0);
|
||||
auto w = str::utf8_char_width(b0);
|
||||
assert (w > 0u);
|
||||
if (w == 1u) {ret b0 as char;}
|
||||
auto val = 0u;
|
||||
|
|
@ -112,7 +112,7 @@ state obj new_reader(buf_reader rdr) {
|
|||
val <<= 6u;
|
||||
val += (next & 0x3f) as uint;
|
||||
}
|
||||
// See _str::char_at
|
||||
// See str::char_at
|
||||
val += ((b0 << ((w + 1u) as u8)) as uint) << ((w - 1u) * 6u - w - 1u);
|
||||
ret val as char;
|
||||
}
|
||||
|
|
@ -126,9 +126,9 @@ state obj new_reader(buf_reader rdr) {
|
|||
while (go_on) {
|
||||
auto ch = rdr.read_byte();
|
||||
if (ch == -1 || ch == 10) {go_on = false;}
|
||||
else {_vec::push[u8](buf, ch as u8);}
|
||||
else {vec::push[u8](buf, ch as u8);}
|
||||
}
|
||||
ret _str::unsafe_from_bytes(buf);
|
||||
ret str::unsafe_from_bytes(buf);
|
||||
}
|
||||
fn read_c_str() -> str {
|
||||
let vec[u8] buf = [];
|
||||
|
|
@ -136,9 +136,9 @@ state obj new_reader(buf_reader rdr) {
|
|||
while (go_on) {
|
||||
auto ch = rdr.read_byte();
|
||||
if (ch < 1) {go_on = false;}
|
||||
else {_vec::push[u8](buf, ch as u8);}
|
||||
else {vec::push[u8](buf, ch as u8);}
|
||||
}
|
||||
ret _str::unsafe_from_bytes(buf);
|
||||
ret str::unsafe_from_bytes(buf);
|
||||
}
|
||||
// FIXME deal with eof?
|
||||
fn read_le_uint(uint size) -> uint {
|
||||
|
|
@ -191,7 +191,7 @@ fn stdin() -> reader {
|
|||
}
|
||||
|
||||
fn file_reader(str path) -> reader {
|
||||
auto f = os::libc::fopen(_str::buf(path), _str::buf("r"));
|
||||
auto f = os::libc::fopen(str::buf(path), str::buf("r"));
|
||||
if (f as uint == 0u) {
|
||||
log_err "error opening " + path;
|
||||
fail;
|
||||
|
|
@ -212,17 +212,17 @@ type byte_buf = @rec(vec[u8] buf, mutable uint pos);
|
|||
|
||||
state obj byte_buf_reader(byte_buf bbuf) {
|
||||
fn read(uint len) -> vec[u8] {
|
||||
auto rest = _vec::len[u8](bbuf.buf) - bbuf.pos;
|
||||
auto rest = vec::len[u8](bbuf.buf) - bbuf.pos;
|
||||
auto to_read = len;
|
||||
if (rest < to_read) {
|
||||
to_read = rest;
|
||||
}
|
||||
auto range = _vec::slice[u8](bbuf.buf, bbuf.pos, bbuf.pos + to_read);
|
||||
auto range = vec::slice[u8](bbuf.buf, bbuf.pos, bbuf.pos + to_read);
|
||||
bbuf.pos += to_read;
|
||||
ret range;
|
||||
}
|
||||
fn read_byte() -> int {
|
||||
if (bbuf.pos == _vec::len[u8](bbuf.buf)) {ret -1;}
|
||||
if (bbuf.pos == vec::len[u8](bbuf.buf)) {ret -1;}
|
||||
auto b = bbuf.buf.(bbuf.pos);
|
||||
bbuf.pos += 1u;
|
||||
ret b as int;
|
||||
|
|
@ -234,12 +234,12 @@ state obj byte_buf_reader(byte_buf bbuf) {
|
|||
}
|
||||
|
||||
fn eof() -> bool {
|
||||
ret bbuf.pos == _vec::len[u8](bbuf.buf);
|
||||
ret bbuf.pos == vec::len[u8](bbuf.buf);
|
||||
}
|
||||
|
||||
fn seek(int offset, seek_style whence) {
|
||||
auto pos = bbuf.pos;
|
||||
auto len = _vec::len[u8](bbuf.buf);
|
||||
auto len = vec::len[u8](bbuf.buf);
|
||||
bbuf.pos = seek_in_buf(offset, pos, len, whence);
|
||||
}
|
||||
|
||||
|
|
@ -270,8 +270,8 @@ type buf_writer = state obj {
|
|||
|
||||
state obj FILE_writer(os::libc::FILE f, bool must_close) {
|
||||
fn write(vec[u8] v) {
|
||||
auto len = _vec::len[u8](v);
|
||||
auto vbuf = _vec::buf[u8](v);
|
||||
auto len = vec::len[u8](v);
|
||||
auto vbuf = vec::buf[u8](v);
|
||||
auto nout = os::libc::fwrite(vbuf, len, 1u, f);
|
||||
if (nout < 1u) {
|
||||
log_err "error dumping buffer";
|
||||
|
|
@ -293,11 +293,11 @@ state obj FILE_writer(os::libc::FILE f, bool must_close) {
|
|||
|
||||
state obj fd_buf_writer(int fd, bool must_close) {
|
||||
fn write(vec[u8] v) {
|
||||
auto len = _vec::len[u8](v);
|
||||
auto len = vec::len[u8](v);
|
||||
auto count = 0u;
|
||||
auto vbuf;
|
||||
while (count < len) {
|
||||
vbuf = _vec::buf_off[u8](v, count);
|
||||
vbuf = vec::buf_off[u8](v, count);
|
||||
auto nout = os::libc::write(fd, vbuf, len);
|
||||
if (nout < 0) {
|
||||
log_err "error dumping buffer";
|
||||
|
|
@ -337,7 +337,7 @@ fn file_buf_writer(str path, vec[fileflag] flags) -> buf_writer {
|
|||
}
|
||||
}
|
||||
|
||||
auto fd = os::libc::open(_str::buf(path),
|
||||
auto fd = os::libc::open(str::buf(path),
|
||||
fflags,
|
||||
os::libc_constants::S_IRUSR() |
|
||||
os::libc_constants::S_IWUSR());
|
||||
|
|
@ -390,17 +390,17 @@ state obj new_writer(buf_writer out) {
|
|||
ret out;
|
||||
}
|
||||
fn write_str(str s) {
|
||||
out.write(_str::bytes(s));
|
||||
out.write(str::bytes(s));
|
||||
}
|
||||
fn write_char(char ch) {
|
||||
// FIXME needlessly consy
|
||||
out.write(_str::bytes(_str::from_char(ch)));
|
||||
out.write(str::bytes(str::from_char(ch)));
|
||||
}
|
||||
fn write_int(int n) {
|
||||
out.write(_str::bytes(_int::to_str(n, 10u)));
|
||||
out.write(str::bytes(int::to_str(n, 10u)));
|
||||
}
|
||||
fn write_uint(uint n) {
|
||||
out.write(_str::bytes(_uint::to_str(n, 10u)));
|
||||
out.write(str::bytes(uint::to_str(n, 10u)));
|
||||
}
|
||||
fn write_bytes(vec[u8] bytes) {
|
||||
out.write(bytes);
|
||||
|
|
@ -427,7 +427,7 @@ fn file_writer(str path, vec[fileflag] flags) -> writer {
|
|||
|
||||
// FIXME: fileflags
|
||||
fn buffered_file_buf_writer(str path) -> buf_writer {
|
||||
auto f = os::libc::fopen(_str::buf(path), _str::buf("w"));
|
||||
auto f = os::libc::fopen(str::buf(path), str::buf("w"));
|
||||
if (f as uint == 0u) {
|
||||
log_err "error opening " + path;
|
||||
fail;
|
||||
|
|
@ -451,21 +451,21 @@ type mutable_byte_buf = @rec(mutable vec[mutable u8] buf, mutable uint pos);
|
|||
state obj byte_buf_writer(mutable_byte_buf buf) {
|
||||
fn write(vec[u8] v) {
|
||||
// Fast path.
|
||||
if (buf.pos == _vec::len(buf.buf)) {
|
||||
if (buf.pos == vec::len(buf.buf)) {
|
||||
// FIXME: Fix our type system. There's no reason you shouldn't be
|
||||
// able to add a mutable vector to an immutable one.
|
||||
auto mv = _vec::rustrt::unsafe_vec_to_mut[u8](v);
|
||||
auto mv = vec::rustrt::unsafe_vec_to_mut[u8](v);
|
||||
buf.buf += mv;
|
||||
buf.pos += _vec::len[u8](v);
|
||||
buf.pos += vec::len[u8](v);
|
||||
ret;
|
||||
}
|
||||
|
||||
// FIXME: Optimize: These should be unique pointers.
|
||||
auto vlen = _vec::len[u8](v);
|
||||
auto vlen = vec::len[u8](v);
|
||||
auto vpos = 0u;
|
||||
while (vpos < vlen) {
|
||||
auto b = v.(vpos);
|
||||
if (buf.pos == _vec::len(buf.buf)) {
|
||||
if (buf.pos == vec::len(buf.buf)) {
|
||||
buf.buf += [mutable b];
|
||||
} else {
|
||||
buf.buf.(buf.pos) = b;
|
||||
|
|
@ -477,7 +477,7 @@ state obj byte_buf_writer(mutable_byte_buf buf) {
|
|||
|
||||
fn seek(int offset, seek_style whence) {
|
||||
auto pos = buf.pos;
|
||||
auto len = _vec::len(buf.buf);
|
||||
auto len = vec::len(buf.buf);
|
||||
buf.pos = seek_in_buf(offset, pos, len, whence);
|
||||
}
|
||||
|
||||
|
|
@ -487,12 +487,12 @@ state obj byte_buf_writer(mutable_byte_buf buf) {
|
|||
fn string_writer() -> str_writer {
|
||||
// FIXME: yikes, this is bad. Needs fixing of mutable syntax.
|
||||
let vec[mutable u8] b = [mutable 0u8];
|
||||
_vec::pop(b);
|
||||
vec::pop(b);
|
||||
|
||||
let mutable_byte_buf buf = @rec(mutable buf = b, mutable pos = 0u);
|
||||
state obj str_writer_wrap(writer wr, mutable_byte_buf 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(buf.buf);}
|
||||
}
|
||||
ret str_writer_wrap(new_writer(byte_buf_writer(buf)), buf);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import _str::sbuf;
|
||||
import _vec::vbuf;
|
||||
import str::sbuf;
|
||||
import vec::vbuf;
|
||||
|
||||
// FIXME Somehow merge stuff duplicated here and macosx_os.rs. Made difficult
|
||||
// by https://github.com/graydon/rust/issues#issue/268
|
||||
|
|
@ -66,17 +66,17 @@ fn dylib_filename(str base) -> str {
|
|||
|
||||
fn pipe() -> tup(int, int) {
|
||||
let vec[mutable int] fds = [mutable 0, 0];
|
||||
assert (os::libc::pipe(_vec::buf(fds)) == 0);
|
||||
assert (os::libc::pipe(vec::buf(fds)) == 0);
|
||||
ret tup(fds.(0), fds.(1));
|
||||
}
|
||||
|
||||
fn fd_FILE(int fd) -> libc::FILE {
|
||||
ret libc::fdopen(fd, _str::buf("r"));
|
||||
ret libc::fdopen(fd, str::buf("r"));
|
||||
}
|
||||
|
||||
fn waitpid(int pid) -> int {
|
||||
let vec[mutable int] status = [mutable 0];
|
||||
assert (os::libc::waitpid(pid, _vec::buf(status), 0) != -1);
|
||||
assert (os::libc::waitpid(pid, vec::buf(status), 0) != -1);
|
||||
ret status.(0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import _str::sbuf;
|
||||
import _vec::vbuf;
|
||||
import str::sbuf;
|
||||
import vec::vbuf;
|
||||
|
||||
native mod libc = "libc.dylib" {
|
||||
|
||||
|
|
@ -63,17 +63,17 @@ fn dylib_filename(str base) -> str {
|
|||
|
||||
fn pipe() -> tup(int, int) {
|
||||
let vec[mutable int] fds = [mutable 0, 0];
|
||||
assert (os::libc::pipe(_vec::buf(fds)) == 0);
|
||||
assert (os::libc::pipe(vec::buf(fds)) == 0);
|
||||
ret tup(fds.(0), fds.(1));
|
||||
}
|
||||
|
||||
fn fd_FILE(int fd) -> libc::FILE {
|
||||
ret libc::fdopen(fd, _str::buf("r"));
|
||||
ret libc::fdopen(fd, str::buf("r"));
|
||||
}
|
||||
|
||||
fn waitpid(int pid) -> int {
|
||||
let vec[mutable int] status = [mutable 0];
|
||||
assert (os::libc::waitpid(pid, _vec::buf(status), 0) != -1);
|
||||
assert (os::libc::waitpid(pid, vec::buf(status), 0) != -1);
|
||||
ret status.(0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
|
|||
}
|
||||
|
||||
fn make_buckets[K, V](uint nbkts) -> vec[mutable bucket[K, V]] {
|
||||
ret _vec::init_elt_mut[bucket[K, V]](nil[K, V], nbkts);
|
||||
ret vec::init_elt_mut[bucket[K, V]](nil[K, V], nbkts);
|
||||
}
|
||||
|
||||
// Derive two hash functions from the one given by taking the upper
|
||||
|
|
@ -148,7 +148,7 @@ fn mk_hashmap[K, V](&hashfn[K] hasher, &eqfn[K] eqer) -> hashmap[K, V] {
|
|||
let util::rational load = rec(num=(nelts + 1u) as int,
|
||||
den=nbkts as int);
|
||||
if (!util::rational_leq(load, lf)) {
|
||||
let uint nnewbkts = _uint::next_power_of_two(nbkts + 1u);
|
||||
let uint nnewbkts = uint::next_power_of_two(nbkts + 1u);
|
||||
let vec[mutable bucket[K, V]] newbkts =
|
||||
make_buckets[K, V](nnewbkts);
|
||||
rehash[K, V](hasher, eqer, bkts, nbkts,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ native "rust" mod rustrt {
|
|||
|
||||
fn list_dir(str path) -> vec[str] {
|
||||
// TODO ensure this is always closed
|
||||
auto dir = os::libc::opendir(_str::buf(path));
|
||||
auto dir = os::libc::opendir(str::buf(path));
|
||||
assert (dir as uint != 0u);
|
||||
let vec[str] result = [];
|
||||
while (true) {
|
||||
|
|
@ -13,7 +13,7 @@ fn list_dir(str path) -> vec[str] {
|
|||
os::libc::closedir(dir);
|
||||
ret result;
|
||||
}
|
||||
_vec::push[str](result, rustrt::rust_dirent_filename(ent));
|
||||
vec::push[str](result, rustrt::rust_dirent_filename(ent));
|
||||
}
|
||||
os::libc::closedir(dir);
|
||||
ret result;
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
import _str::sbuf;
|
||||
import _vec::vbuf;
|
||||
import str::sbuf;
|
||||
import vec::vbuf;
|
||||
|
||||
native "rust" mod rustrt {
|
||||
fn rust_run_program(vbuf argv, int in_fd, int out_fd, int err_fd) -> int;
|
||||
}
|
||||
|
||||
fn arg_vec(str prog, vec[str] args) -> vec[sbuf] {
|
||||
auto argptrs = [_str::buf(prog)];
|
||||
auto argptrs = [str::buf(prog)];
|
||||
for (str arg in args) {
|
||||
_vec::push[sbuf](argptrs, _str::buf(arg));
|
||||
vec::push[sbuf](argptrs, str::buf(arg));
|
||||
}
|
||||
_vec::push[sbuf](argptrs, 0 as sbuf);
|
||||
vec::push[sbuf](argptrs, 0 as sbuf);
|
||||
ret argptrs;
|
||||
}
|
||||
|
||||
fn run_program(str prog, vec[str] args) -> int {
|
||||
auto pid = rustrt::rust_run_program(_vec::buf[sbuf](arg_vec(prog, args)),
|
||||
auto pid = rustrt::rust_run_program(vec::buf[sbuf](arg_vec(prog, args)),
|
||||
0, 0, 0);
|
||||
ret os::waitpid(pid);
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ fn start_program(str prog, vec[str] args) -> @program {
|
|||
auto pipe_input = os::pipe();
|
||||
auto pipe_output = os::pipe();
|
||||
auto pid = rustrt::rust_run_program
|
||||
(_vec::buf[sbuf](arg_vec(prog, args)),
|
||||
(vec::buf[sbuf](arg_vec(prog, args)),
|
||||
pipe_input._0, pipe_output._1, 0);
|
||||
if (pid == -1) {fail;}
|
||||
os::libc::close(pipe_input._0);
|
||||
|
|
@ -80,7 +80,7 @@ fn program_output(str prog, vec[str] args)
|
|||
auto buf = "";
|
||||
while (!out.eof()) {
|
||||
auto bytes = out.read_bytes(4096u);
|
||||
buf += _str::unsafe_from_bytes(bytes);
|
||||
buf += str::unsafe_from_bytes(bytes);
|
||||
}
|
||||
ret rec(status=pr.finish(), out=buf);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ fn mk_sha1() -> sha1 {
|
|||
fn process_msg_block(&sha1state st) {
|
||||
|
||||
// FIXME: Make precondition
|
||||
assert (_vec::len(st.h) == digest_buf_len);
|
||||
assert (_vec::len(st.work_buf) == work_buf_len);
|
||||
assert (vec::len(st.h) == digest_buf_len);
|
||||
assert (vec::len(st.work_buf) == work_buf_len);
|
||||
|
||||
let int t; // Loop counter
|
||||
auto w = st.work_buf;
|
||||
|
|
@ -196,7 +196,7 @@ fn mk_sha1() -> sha1 {
|
|||
*/
|
||||
fn pad_msg(&sha1state st) {
|
||||
// FIXME: Should be a precondition
|
||||
assert (_vec::len(st.msg_block) == msg_block_len);
|
||||
assert (vec::len(st.msg_block) == msg_block_len);
|
||||
|
||||
/*
|
||||
* Check to see if the current message block is too small to hold
|
||||
|
|
@ -240,7 +240,7 @@ fn mk_sha1() -> sha1 {
|
|||
|
||||
fn reset() {
|
||||
// FIXME: Should be typestate precondition
|
||||
assert (_vec::len(st.h) == digest_buf_len);
|
||||
assert (vec::len(st.h) == digest_buf_len);
|
||||
|
||||
st.len_low = 0u32;
|
||||
st.len_high = 0u32;
|
||||
|
|
@ -260,7 +260,7 @@ fn mk_sha1() -> sha1 {
|
|||
}
|
||||
|
||||
fn input_str(&str msg) {
|
||||
add_input(st, _str::bytes(msg));
|
||||
add_input(st, str::bytes(msg));
|
||||
}
|
||||
|
||||
fn result() -> vec[u8] {
|
||||
|
|
@ -271,19 +271,19 @@ fn mk_sha1() -> sha1 {
|
|||
auto r = mk_result(st);
|
||||
auto s = "";
|
||||
for (u8 b in r) {
|
||||
s += _uint::to_str(b as uint, 16u);
|
||||
s += uint::to_str(b as uint, 16u);
|
||||
}
|
||||
ret s;
|
||||
}
|
||||
}
|
||||
|
||||
auto st = rec(h = _vec::init_elt_mut[u32](0u32, digest_buf_len),
|
||||
auto st = rec(h = vec::init_elt_mut[u32](0u32, digest_buf_len),
|
||||
mutable len_low = 0u32,
|
||||
mutable len_high = 0u32,
|
||||
msg_block = _vec::init_elt_mut[u8](0u8, msg_block_len),
|
||||
msg_block = vec::init_elt_mut[u8](0u8, msg_block_len),
|
||||
mutable msg_block_idx = 0u,
|
||||
mutable computed = false,
|
||||
work_buf = _vec::init_elt_mut[u32](0u32, work_buf_len));
|
||||
work_buf = vec::init_elt_mut[u32](0u32, work_buf_len));
|
||||
auto sh = sha1(st);
|
||||
sh.reset();
|
||||
ret sh;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import _vec::len;
|
||||
import _vec::slice;
|
||||
import vec::len;
|
||||
import vec::slice;
|
||||
|
||||
type lteq[T] = fn(&T a, &T b) -> bool;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ meta (name = "std",
|
|||
|
||||
// Built-in types support modules.
|
||||
|
||||
mod _int;
|
||||
mod _uint;
|
||||
mod _u8;
|
||||
mod _vec;
|
||||
mod _str;
|
||||
mod int;
|
||||
mod uint;
|
||||
mod u8;
|
||||
mod vec;
|
||||
mod str;
|
||||
|
||||
// General io and system-services modules.
|
||||
|
||||
|
|
@ -29,13 +29,13 @@ auth io = unsafe;
|
|||
auth fs = unsafe;
|
||||
auth os_fs = unsafe;
|
||||
auth run = unsafe;
|
||||
auth _str = unsafe;
|
||||
auth _vec = unsafe;
|
||||
auth str = unsafe;
|
||||
auth vec = unsafe;
|
||||
auth _task = unsafe;
|
||||
|
||||
auth dbg = unsafe;
|
||||
|
||||
auth _uint::next_power_of_two = unsafe;
|
||||
auth uint::next_power_of_two = unsafe;
|
||||
auth map::mk_hashmap = unsafe;
|
||||
auth rand::mk_rng = unsafe;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import rustrt::sbuf;
|
||||
|
||||
import _vec::rustrt::vbuf;
|
||||
import vec::rustrt::vbuf;
|
||||
|
||||
native "rust" mod rustrt {
|
||||
type sbuf;
|
||||
|
|
@ -84,7 +84,7 @@ const uint tag_six_b = 0xfc_u;
|
|||
|
||||
fn is_utf8(vec[u8] v) -> bool {
|
||||
auto i = 0u;
|
||||
auto total = _vec::len[u8](v);
|
||||
auto total = vec::len[u8](v);
|
||||
while (i < total) {
|
||||
auto chsize = utf8_char_width(v.(i));
|
||||
if (chsize == 0u) {ret false;}
|
||||
|
|
@ -253,7 +253,7 @@ fn to_chars(str s) -> vec[char] {
|
|||
auto len = byte_len(s);
|
||||
while (i < len) {
|
||||
auto cur = char_range_at(s, i);
|
||||
_vec::push[char](buf, cur._0);
|
||||
vec::push[char](buf, cur._0);
|
||||
i = cur._1;
|
||||
}
|
||||
ret buf;
|
||||
|
|
@ -311,7 +311,7 @@ fn index(str s, u8 c) -> int {
|
|||
}
|
||||
|
||||
fn rindex(str s, u8 c) -> int {
|
||||
let int n = _str::byte_len(s) as int;
|
||||
let int n = str::byte_len(s) as int;
|
||||
while (n >= 0) {
|
||||
if (s.(n) == c) {
|
||||
ret n;
|
||||
|
|
@ -387,7 +387,7 @@ fn substr(str s, uint begin, uint len) -> str {
|
|||
fn slice(str s, uint begin, uint end) -> str {
|
||||
// FIXME: Typestate precondition
|
||||
assert (begin <= end);
|
||||
assert (end <= _str::byte_len(s));
|
||||
assert (end <= str::byte_len(s));
|
||||
ret rustrt::str_slice(s, begin, end);
|
||||
}
|
||||
|
||||
|
|
@ -432,7 +432,7 @@ fn split(str s, u8 sep) -> vec[str] {
|
|||
ends_with_sep = false;
|
||||
}
|
||||
}
|
||||
if (_str::byte_len(accum) != 0u ||
|
||||
if (str::byte_len(accum) != 0u ||
|
||||
ends_with_sep) {
|
||||
v += [accum];
|
||||
}
|
||||
|
|
@ -8,12 +8,12 @@ type ufind = rec(mutable vec[mutable node] nodes);
|
|||
|
||||
fn make() -> ufind {
|
||||
let vec[mutable node] v = [mutable none[uint]];
|
||||
_vec::pop(v); // FIXME: botch
|
||||
vec::pop(v); // FIXME: botch
|
||||
ret rec(mutable nodes=v);
|
||||
}
|
||||
|
||||
fn make_set(&ufind ufnd) -> uint {
|
||||
auto idx = _vec::len(ufnd.nodes);
|
||||
auto idx = vec::len(ufnd.nodes);
|
||||
ufnd.nodes += [mutable none[uint]];
|
||||
ret idx;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,12 +34,12 @@ fn next_power_of_two(uint n) -> uint {
|
|||
}
|
||||
|
||||
fn parse_buf(vec[u8] buf, uint radix) -> uint {
|
||||
if (_vec::len[u8](buf) == 0u) {
|
||||
if (vec::len[u8](buf) == 0u) {
|
||||
log_err "parse_buf(): buf is empty";
|
||||
fail;
|
||||
}
|
||||
|
||||
auto i = _vec::len[u8](buf) - 1u;
|
||||
auto i = vec::len[u8](buf) - 1u;
|
||||
auto power = 1u;
|
||||
auto n = 0u;
|
||||
while (true) {
|
||||
|
|
@ -83,15 +83,15 @@ fn to_str(uint num, uint radix) -> str
|
|||
|
||||
let str s = "";
|
||||
while (n != 0u) {
|
||||
s += _str::unsafe_from_byte(digit(n % radix) as u8);
|
||||
s += str::unsafe_from_byte(digit(n % radix) as u8);
|
||||
n /= radix;
|
||||
}
|
||||
|
||||
let str s1 = "";
|
||||
let uint len = _str::byte_len(s);
|
||||
let uint len = str::byte_len(s);
|
||||
while (len != 0u) {
|
||||
len -= 1u;
|
||||
s1 += _str::unsafe_from_byte(s.(len));
|
||||
s1 += str::unsafe_from_byte(s.(len));
|
||||
}
|
||||
ret s1;
|
||||
|
||||
|
|
@ -4,7 +4,7 @@ fn id[T](&T x) -> T {
|
|||
|
||||
/* FIXME (issue #141): See test/run-pass/constrained-type.rs. Uncomment
|
||||
* the constraint once fixed. */
|
||||
type rational = rec(int num, int den); // : _int::positive(*.den);
|
||||
type rational = rec(int num, int den); // : int::positive(*.den);
|
||||
|
||||
fn rational_leq(&rational x, &rational y) -> bool {
|
||||
// NB: Uses the fact that rationals have positive denominators WLOG:
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ fn grow[T](&array[T] v, uint n, &T initval) {
|
|||
}
|
||||
|
||||
fn grow_set[T](&vec[mutable T] v, uint index, &T initval, &T val) {
|
||||
auto length = _vec::len(v);
|
||||
auto length = vec::len(v);
|
||||
if (index >= length) {
|
||||
grow(v, index - length + 1u, initval);
|
||||
}
|
||||
|
|
@ -270,7 +270,7 @@ fn unzip[T, U](&vec[tup(T, U)] v) -> tup(vec[T], vec[U]) {
|
|||
|
||||
fn or(&vec[bool] v) -> bool {
|
||||
auto f = orb;
|
||||
ret _vec::foldl[bool, bool](f, false, v);
|
||||
ret vec::foldl[bool, bool](f, false, v);
|
||||
}
|
||||
|
||||
fn clone[T](&vec[T] v) -> vec[T] {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import _str::sbuf;
|
||||
import _vec::vbuf;
|
||||
import str::sbuf;
|
||||
import vec::vbuf;
|
||||
|
||||
native mod libc = "msvcrt.dll" {
|
||||
fn open(sbuf s, int flags, uint mode) -> int = "_open";
|
||||
|
|
@ -53,13 +53,13 @@ fn dylib_filename(str base) -> str {
|
|||
|
||||
fn pipe() -> tup(int, int) {
|
||||
let vec[mutable int] fds = [mutable 0, 0];
|
||||
assert (os::libc::_pipe(_vec::buf(fds), 1024u,
|
||||
assert (os::libc::_pipe(vec::buf(fds), 1024u,
|
||||
libc_constants::O_BINARY()) == 0);
|
||||
ret tup(fds.(0), fds.(1));
|
||||
}
|
||||
|
||||
fn fd_FILE(int fd) -> libc::FILE {
|
||||
ret libc::_fdopen(fd, _str::buf("r"));
|
||||
ret libc::_fdopen(fd, str::buf("r"));
|
||||
}
|
||||
|
||||
native "rust" mod rustrt {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue