Permalink
Browse files

(core::str) remove len_bytes alias

  • Loading branch information...
1 parent 1b957c0 commit 7782f5d6926be7970ec474b74302f2298ceccd13 @killerswan killerswan committed with marijnh Feb 23, 2012
View
@@ -174,10 +174,10 @@ fn print(s: str) {
}
fn rest(s: str, start: uint) -> str {
- if (start >= str::len_bytes(s)) {
+ if (start >= str::len(s)) {
""
} else {
- str::slice(s, start, str::len_bytes(s))
+ str::slice(s, start, str::len(s))
}
}
@@ -689,7 +689,7 @@ fn cmd_install(c: cargo) unsafe {
alt str::index(uuid, '/') {
option::some(idx) {
let source = str::slice(uuid, 0u, idx);
- uuid = str::slice(uuid, idx + 1u, str::len_bytes(uuid));
+ uuid = str::slice(uuid, idx + 1u, str::len(uuid));
install_uuid_specific(c, wd, source, uuid);
}
option::none {
@@ -701,7 +701,7 @@ fn cmd_install(c: cargo) unsafe {
alt str::index(name, '/') {
option::some(idx) {
let source = str::slice(name, 0u, idx);
- name = str::slice(name, idx + 1u, str::len_bytes(name));
+ name = str::slice(name, idx + 1u, str::len(name));
install_named_specific(c, wd, source, name);
}
option::none {
View
@@ -395,7 +395,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
metas: provided_metas,
dep_hashes: [str]) -> str {
fn len_and_str(s: str) -> str {
- ret #fmt["%u_%s", str::len_bytes(s), s];
+ ret #fmt["%u_%s", str::len(s), s];
}
fn len_and_str_lit(l: ast::lit) -> str {
@@ -520,7 +520,7 @@ fn mangle(ss: path) -> str {
for s in ss {
alt s { path_name(s) | path_mod(s) {
- n += #fmt["%u%s", str::len_bytes(s), s];
+ n += #fmt["%u%s", str::len(s), s];
} }
}
n += "E"; // End name-sequence.
@@ -572,8 +572,7 @@ fn link_binary(sess: session,
(config.os == session::os_linux ||
config.os == session::os_freebsd) &&
option::is_some(found) && option::get(found) == 0u {
- ret str::slice(filename, 3u,
- str::len_bytes(filename));
+ ret str::slice(filename, 3u, str::len(filename));
} else { ret filename; }
};
fn rmext(filename: str) -> str {
@@ -210,7 +210,7 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
if elided {
let last_line = display_lines[vec::len(display_lines) - 1u];
let s = #fmt["%s:%u ", fm.name, last_line + 1u];
- let indent = str::len_bytes(s);
+ let indent = str::len(s);
let out = "";
while indent > 0u { out += " "; indent -= 1u; }
out += "...\n";
@@ -228,7 +228,7 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
while num > 0u { num /= 10u; digits += 1u; }
// indent past |name:## | and the 0-offset column location
- let left = str::len_bytes(fm.name) + digits + lo.col + 3u;
+ let left = str::len(fm.name) + digits + lo.col + 3u;
let s = "";
while left > 0u { str::push_char(s, ' '); left -= 1u; }
View
@@ -13,7 +13,7 @@ import rustc::driver::diagnostic;
fn version(argv0: str) {
let vers = "unknown version";
let env_vers = #env["CFG_VERSION"];
- if str::len_bytes(env_vers) != 0u { vers = env_vers; }
+ if str::len(env_vers) != 0u { vers = env_vers; }
io::stdout().write_str(#fmt["%s %s\n", argv0, vers]);
io::stdout().write_str(#fmt["host: %s\n", host_triple()]);
}
@@ -777,7 +777,7 @@ fn C_u8(i: uint) -> ValueRef { ret C_integral(T_i8(), i as u64, False); }
// our boxed-and-length-annotated strings.
fn C_cstr(cx: crate_ctxt, s: str) -> ValueRef {
let sc = str::as_buf(s) {|buf|
- llvm::LLVMConstString(buf, str::len_bytes(s) as unsigned, False)
+ llvm::LLVMConstString(buf, str::len(s) as unsigned, False)
};
let g =
str::as_buf(cx.names("str"),
@@ -791,7 +791,7 @@ fn C_cstr(cx: crate_ctxt, s: str) -> ValueRef {
// Returns a Plain Old LLVM String:
fn C_postr(s: str) -> ValueRef {
ret str::as_buf(s) {|buf|
- llvm::LLVMConstString(buf, str::len_bytes(s) as unsigned, False)
+ llvm::LLVMConstString(buf, str::len(s) as unsigned, False)
};
}
@@ -48,7 +48,7 @@ const DW_ATE_unsigned_char: int = 0x08;
fn llstr(s: str) -> ValueRef {
str::as_buf(s, {|sbuf|
- llvm::LLVMMDString(sbuf, str::len_bytes(s) as ctypes::c_uint)
+ llvm::LLVMMDString(sbuf, str::len(s) as ctypes::c_uint)
})
}
fn lltag(lltag: int) -> ValueRef {
@@ -167,8 +167,7 @@ fn create_compile_unit(cx: crate_ctxt, full_path: str)
let work_dir = cx.sess.working_dir;
let file_path = if str::starts_with(full_path, work_dir) {
- str::slice(full_path, str::len_bytes(work_dir),
- str::len_bytes(full_path))
+ str::slice(full_path, str::len(work_dir), str::len(full_path))
} else {
full_path
};
@@ -126,7 +126,7 @@ fn trans_vec(bcx: block, args: [@ast::expr], id: ast::node_id,
}
fn trans_str(bcx: block, s: str, dest: dest) -> block {
- let veclen = str::len_bytes(s) + 1u; // +1 for \0
+ let veclen = str::len(s) + 1u; // +1 for \0
let {bcx: bcx, val: sptr, _} =
alloc(bcx, ty::mk_str(bcx.tcx()), veclen);
@@ -157,10 +157,9 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines {
fn get_line(fm: filemap, line: int) -> str unsafe {
let begin: uint = fm.lines[line].byte - fm.start_pos.byte;
- let end = alt str::index_from(*fm.src, '\n', begin,
- str::len_bytes(*fm.src)) {
+ let end = alt str::index_from(*fm.src, '\n', begin, str::len(*fm.src)) {
some(e) { e }
- none { str::len_bytes(*fm.src) }
+ none { str::len(*fm.src) }
};
str::slice(*fm.src, begin, end)
}
@@ -64,7 +64,7 @@ fn new_reader(cm: codemap::codemap,
itr: @interner::interner<str>) -> reader {
let r = @{cm: cm,
span_diagnostic: span_diagnostic,
- src: filemap.src, len: str::len_bytes(*filemap.src),
+ src: filemap.src, len: str::len(*filemap.src),
mutable col: 0u, mutable pos: 0u, mutable curr: -1 as char,
mutable chpos: filemap.start_pos.ch, mutable strs: [],
filemap: filemap, interner: itr};
@@ -163,7 +163,7 @@ fn scan_exponent(rdr: reader) -> option<str> {
rdr.bump();
}
let exponent = scan_digits(rdr, 10u);
- if str::len_bytes(exponent) > 0u {
+ if str::len(exponent) > 0u {
ret some(rslt + exponent);
} else { rdr.fatal("scan_exponent: bad fp literal"); }
} else { ret none::<str>; }
@@ -226,7 +226,7 @@ fn scan_number(c: char, rdr: reader) -> token::token {
tp = if signed { either::left(ast::ty_i64) }
else { either::right(ast::ty_u64) };
}
- if str::len_bytes(num_str) == 0u {
+ if str::len(num_str) == 0u {
rdr.fatal("no valid digits found for number");
}
let parsed = option::get(u64::from_str(num_str, base as u64));
@@ -273,7 +273,7 @@ fn scan_number(c: char, rdr: reader) -> token::token {
ret token::LIT_FLOAT(interner::intern(*rdr.interner, num_str),
ast::ty_f);
} else {
- if str::len_bytes(num_str) == 0u {
+ if str::len(num_str) == 0u {
rdr.fatal("no valid digits found for number");
}
let parsed = option::get(u64::from_str(num_str, base as u64));
@@ -610,8 +610,8 @@ fn trim_whitespace_prefix_and_push_line(&lines: [str],
s: str, col: uint) unsafe {
let s1;
if all_whitespace(s, 0u, col) {
- if col < str::len_bytes(s) {
- s1 = str::slice(s, col, str::len_bytes(s));
+ if col < str::len(s) {
+ s1 = str::slice(s, col, str::len(s));
} else { s1 = ""; }
} else { s1 = s; }
log(debug, "pushing line: " + s1);
@@ -651,7 +651,7 @@ fn read_block_comment(rdr: reader, code_to_the_left: bool) -> cmnt {
}
}
}
- if str::len_bytes(curr_line) != 0u {
+ if str::len(curr_line) != 0u {
trim_whitespace_prefix_and_push_line(lines, curr_line, col);
}
let style = if code_to_the_left { trailing } else { isolated };
@@ -491,7 +491,7 @@ fn end(p: printer) { p.pretty_print(END); }
fn eof(p: printer) { p.pretty_print(EOF); }
fn word(p: printer, wrd: str) {
- p.pretty_print(STRING(wrd, str::len_bytes(wrd) as int));
+ p.pretty_print(STRING(wrd, str::len(wrd) as int));
}
fn huge_word(p: printer, wrd: str) {
@@ -204,7 +204,7 @@ fn head(s: ps, w: str) {
// outer-box is consistent
cbox(s, indent_unit);
// head-box is inconsistent
- ibox(s, str::len_bytes(w) + 1u);
+ ibox(s, str::len(w) + 1u);
// keyword that starts the head
word_nbsp(s, w);
}
@@ -1465,7 +1465,7 @@ fn print_ty_fn(s: ps, opt_proto: option<ast::proto>,
popen(s);
fn print_arg(s: ps, input: ast::arg) {
print_arg_mode(s, input.mode);
- if str::len_bytes(input.ident) > 0u {
+ if str::len(input.ident) > 0u {
word_space(s, input.ident + ":");
}
print_type(s, input.ty);
@@ -1647,7 +1647,7 @@ fn print_string(s: ps, st: str) {
fn escape_str(st: str, to_escape: char) -> str {
let out: str = "";
- let len = str::len_bytes(st);
+ let len = str::len(st);
let i = 0u;
while i < len {
alt st[i] as char {
View
@@ -129,9 +129,9 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
}
}
-fn ty_to_short_str(cx: ctxt, typ: t) -> str unsafe {
+fn ty_to_short_str(cx: ctxt, typ: t) -> str {
let s = encoder::encoded_ty(cx, typ);
- if str::len_bytes(s) >= 32u { s = str::slice(s, 0u, 32u); }
+ if str::len(s) >= 32u { s = str::slice(s, 0u, 32u); }
ret s;
}
@@ -27,13 +27,13 @@ fn parse_expected(line_num: uint, line: str) -> [expected_error] unsafe {
let idx;
alt str::find(line, error_tag) {
option::none { ret []; }
- option::some(nn) { idx = (nn as uint) + str::len_bytes(error_tag); }
+ option::some(nn) { idx = (nn as uint) + str::len(error_tag); }
}
// "//!^^^ kind msg" denotes a message expected
// three lines above current line:
let adjust_line = 0u;
- let len = str::len_bytes(line);
+ let len = str::len(line);
while idx < len && line[idx] == ('^' as u8) {
adjust_line += 1u;
idx += 1u;
@@ -108,10 +108,8 @@ fn parse_name_value_directive(line: str,
let keycolon = directive + ":";
alt str::find(line, keycolon) {
option::some(colon) {
- let value =
- str::slice(line,
- colon + str::len_bytes(keycolon),
- str::len_bytes(line));
+ let value = str::slice(line, colon + str::len(keycolon),
+ str::len(line));
#debug("%s: %s", directive, value);
option::some(value)
}
View
@@ -287,7 +287,7 @@ fn check_variants_T<T: copy>(
fn last_part(filename: str) -> str {
let ix = option::get(str::rindex(filename, '/'));
- str::slice(filename, ix + 1u, str::len_bytes(filename) - 3u)
+ str::slice(filename, ix + 1u, str::len(filename) - 3u)
}
enum happiness { passed, cleanly_rejected(str), known_bug(str), failed(str), }
@@ -335,7 +335,7 @@ fn removeDirIfExists(filename: str) {
fn check_running(exe_filename: str) -> happiness {
let p = std::run::program_output("/Users/jruderman/scripts/timed_run_rust_program.py", [exe_filename]);
let comb = p.out + "\n" + p.err;
- if str::len_bytes(comb) > 1u {
+ if str::len(comb) > 1u {
log(error, "comb comb comb: " + comb);
}
View
@@ -82,10 +82,10 @@ mod ct {
fn parse_fmt_string(s: str, error: error_fn) -> [piece] unsafe {
let pieces: [piece] = [];
- let lim = str::len_bytes(s);
+ let lim = str::len(s);
let buf = "";
fn flush_buf(buf: str, &pieces: [piece]) -> str {
- if str::len_bytes(buf) > 0u {
+ if str::len(buf) > 0u {
let piece = piece_string(buf);
pieces += [piece];
}
@@ -433,12 +433,12 @@ mod rt {
// zeros. It may make sense to convert zero padding to a precision
// instead.
- if signed && zero_padding && str::len_bytes(s) > 0u {
+ if signed && zero_padding && str::len(s) > 0u {
let head = s[0];
if head == '+' as u8 || head == '-' as u8 || head == ' ' as u8 {
let headstr = str::from_bytes([head]);
// FIXME: not UTF-8 safe
- let bytelen = str::len_bytes(s);
+ let bytelen = str::len(s);
let numpart = str::slice(s, 1u, bytelen);
ret headstr + padstr + numpart;
}
View
@@ -133,7 +133,7 @@ number represented by [num].
fn from_str(num: str) -> option<float> {
let pos = 0u; //Current byte position in the string.
//Used to walk the string in O(n).
- let len = str::len_bytes(num); //Length of the string, in bytes.
+ let len = str::len(num); //Length of the string, in bytes.
if len == 0u { ret none; }
let total = 0f; //Accumulated result
Oops, something went wrong.

0 comments on commit 7782f5d

Please sign in to comment.