Skip to content

Commit 2b4f513

Browse files
committed
(core::str) rename byte_len -> len_bytes and rename char_len -> len
1 parent 944f5a6 commit 2b4f513

34 files changed

+123
-119
lines changed

src/cargo/cargo.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ fn print(s: str) {
174174
}
175175

176176
fn rest(s: str, start: uint) -> str {
177-
if (start >= str::char_len(s)) {
177+
if (start >= str::len(s)) {
178178
""
179179
} else {
180-
str::slice(s, start, str::char_len(s))
180+
str::slice(s, start, str::len(s))
181181
}
182182
}
183183

@@ -654,7 +654,7 @@ fn cmd_install(c: cargo) unsafe {
654654
alt str::index(uuid, '/') {
655655
option::some(idx) {
656656
let source = str::slice(uuid, 0u, idx);
657-
uuid = str::slice(uuid, idx + 1u, str::char_len(uuid));
657+
uuid = str::slice(uuid, idx + 1u, str::len(uuid));
658658
install_uuid_specific(c, wd, source, uuid);
659659
}
660660
option::none {
@@ -666,7 +666,7 @@ fn cmd_install(c: cargo) unsafe {
666666
alt str::index(name, '/') {
667667
option::some(idx) {
668668
let source = str::slice(name, 0u, idx);
669-
name = str::slice(name, idx + 1u, str::char_len(name));
669+
name = str::slice(name, idx + 1u, str::len(name));
670670
install_named_specific(c, wd, source, name);
671671
}
672672
option::none {

src/comp/back/link.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
396396
metas: provided_metas,
397397
dep_hashes: [str]) -> str {
398398
fn len_and_str(s: str) -> str {
399-
ret #fmt["%u_%s", str::byte_len(s), s];
399+
ret #fmt["%u_%s", str::len_bytes(s), s];
400400
}
401401

402402
fn len_and_str_lit(l: ast::lit) -> str {
@@ -521,7 +521,7 @@ fn mangle(ss: path) -> str {
521521

522522
for s in ss {
523523
alt s { path_name(s) | path_mod(s) {
524-
n += #fmt["%u%s", str::byte_len(s), s];
524+
n += #fmt["%u%s", str::len_bytes(s), s];
525525
} }
526526
}
527527
n += "E"; // End name-sequence.
@@ -573,7 +573,7 @@ fn link_binary(sess: session,
573573
config.os == session::os_freebsd) &&
574574
str::find(filename, "lib") == 0 {
575575
ret str::unsafe::slice_bytes(filename, 3u,
576-
str::byte_len(filename));
576+
str::len_bytes(filename));
577577
} else { ret filename; }
578578
};
579579
fn rmext(filename: str) -> str {

src/comp/driver/diagnostic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
210210
if elided {
211211
let last_line = display_lines[vec::len(display_lines) - 1u];
212212
let s = #fmt["%s:%u ", fm.name, last_line + 1u];
213-
let indent = str::char_len(s);
213+
let indent = str::len(s);
214214
let out = "";
215215
while indent > 0u { out += " "; indent -= 1u; }
216216
out += "...\n";
@@ -228,7 +228,7 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
228228
while num > 0u { num /= 10u; digits += 1u; }
229229

230230
// indent past |name:## | and the 0-offset column location
231-
let left = str::char_len(fm.name) + digits + lo.col + 3u;
231+
let left = str::len(fm.name) + digits + lo.col + 3u;
232232
let s = "";
233233
while left > 0u { str::push_char(s, ' '); left -= 1u; }
234234

src/comp/driver/rustc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import rustc::driver::diagnostic;
1313
fn version(argv0: str) {
1414
let vers = "unknown version";
1515
let env_vers = #env["CFG_VERSION"];
16-
if str::byte_len(env_vers) != 0u { vers = env_vers; }
16+
if str::len_bytes(env_vers) != 0u { vers = env_vers; }
1717
io::stdout().write_str(#fmt["%s %s\n", argv0, vers]);
1818
io::stdout().write_str(#fmt["host: %s\n", host_triple()]);
1919
}

src/comp/middle/debuginfo.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const DW_ATE_unsigned_char: int = 0x08;
4848

4949
fn llstr(s: str) -> ValueRef {
5050
str::as_buf(s, {|sbuf|
51-
llvm::LLVMMDString(sbuf, str::byte_len(s) as ctypes::c_uint)
51+
llvm::LLVMMDString(sbuf, str::len_bytes(s) as ctypes::c_uint)
5252
})
5353
}
5454
fn lltag(lltag: int) -> ValueRef {
@@ -167,8 +167,8 @@ fn create_compile_unit(cx: @crate_ctxt, full_path: str)
167167

168168
let work_dir = cx.sess.working_dir;
169169
let file_path = if str::starts_with(full_path, work_dir) {
170-
str::unsafe::slice_bytes(full_path, str::byte_len(work_dir),
171-
str::byte_len(full_path))
170+
str::unsafe::slice_bytes(full_path, str::len_bytes(work_dir),
171+
str::len_bytes(full_path))
172172
} else {
173173
full_path
174174
};

src/comp/middle/trans/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ fn C_u8(i: uint) -> ValueRef { ret C_integral(T_i8(), i as u64, False); }
767767
// our boxed-and-length-annotated strings.
768768
fn C_cstr(cx: @crate_ctxt, s: str) -> ValueRef {
769769
let sc = str::as_buf(s) {|buf|
770-
llvm::LLVMConstString(buf, str::byte_len(s) as unsigned, False)
770+
llvm::LLVMConstString(buf, str::len_bytes(s) as unsigned, False)
771771
};
772772
let g =
773773
str::as_buf(cx.names("str"),
@@ -781,7 +781,7 @@ fn C_cstr(cx: @crate_ctxt, s: str) -> ValueRef {
781781
// Returns a Plain Old LLVM String:
782782
fn C_postr(s: str) -> ValueRef {
783783
ret str::as_buf(s) {|buf|
784-
llvm::LLVMConstString(buf, str::byte_len(s) as unsigned, False)
784+
llvm::LLVMConstString(buf, str::len_bytes(s) as unsigned, False)
785785
};
786786
}
787787

src/comp/middle/trans/tvec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ fn trans_vec(bcx: @block_ctxt, args: [@ast::expr], id: ast::node_id,
130130
}
131131

132132
fn trans_str(bcx: @block_ctxt, s: str, dest: dest) -> @block_ctxt {
133-
let veclen = str::byte_len(s) + 1u; // +1 for \0
133+
let veclen = str::len_bytes(s) + 1u; // +1 for \0
134134
let {bcx: bcx, val: sptr, _} =
135135
alloc(bcx, ty::mk_str(bcx_tcx(bcx)), veclen);
136136

src/comp/syntax/ext/qquote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ fn expand_qquote<N: qq_helper>
202202
if (j < g_len && i == cx.gather[j].lo) {
203203
assert ch == '$';
204204
let repl = #fmt("$%u ", j);
205-
state = skip(str::char_len(repl));
205+
state = skip(str::len(repl));
206206
str2 += repl;
207207
}
208208
alt state {

src/comp/syntax/parse/lexer.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn new_reader(cm: codemap::codemap,
5858
itr: @interner::interner<str>) -> reader {
5959
let r = @{cm: cm,
6060
span_diagnostic: span_diagnostic,
61-
src: filemap.src, len: str::byte_len(*filemap.src),
61+
src: filemap.src, len: str::len_bytes(*filemap.src),
6262
mutable col: 0u, mutable pos: 0u, mutable curr: -1 as char,
6363
mutable chpos: filemap.start_pos.ch, mutable strs: [],
6464
filemap: filemap, interner: itr};
@@ -157,7 +157,7 @@ fn scan_exponent(rdr: reader) -> option<str> {
157157
rdr.bump();
158158
}
159159
let exponent = scan_digits(rdr, 10u);
160-
if str::byte_len(exponent) > 0u {
160+
if str::len_bytes(exponent) > 0u {
161161
ret some(rslt + exponent);
162162
} else { rdr.fatal("scan_exponent: bad fp literal"); }
163163
} else { ret none::<str>; }
@@ -220,7 +220,7 @@ fn scan_number(c: char, rdr: reader) -> token::token {
220220
tp = if signed { either::left(ast::ty_i64) }
221221
else { either::right(ast::ty_u64) };
222222
}
223-
if str::byte_len(num_str) == 0u {
223+
if str::len_bytes(num_str) == 0u {
224224
rdr.fatal("no valid digits found for number");
225225
}
226226
let parsed = u64::from_str(num_str, base as u64);
@@ -267,7 +267,7 @@ fn scan_number(c: char, rdr: reader) -> token::token {
267267
ret token::LIT_FLOAT(interner::intern(*rdr.interner, num_str),
268268
ast::ty_f);
269269
} else {
270-
if str::byte_len(num_str) == 0u {
270+
if str::len_bytes(num_str) == 0u {
271271
rdr.fatal("no valid digits found for number");
272272
}
273273
let parsed = u64::from_str(num_str, base as u64);
@@ -604,8 +604,8 @@ fn trim_whitespace_prefix_and_push_line(&lines: [str],
604604
s: str, col: uint) unsafe {
605605
let s1;
606606
if all_whitespace(s, 0u, col) {
607-
if col < str::byte_len(s) {
608-
s1 = str::unsafe::slice_bytes(s, col, str::byte_len(s));
607+
if col < str::len_bytes(s) {
608+
s1 = str::unsafe::slice_bytes(s, col, str::len_bytes(s));
609609
} else { s1 = ""; }
610610
} else { s1 = s; }
611611
log(debug, "pushing line: " + s1);
@@ -645,7 +645,7 @@ fn read_block_comment(rdr: reader, code_to_the_left: bool) -> cmnt {
645645
}
646646
}
647647
}
648-
if str::byte_len(curr_line) != 0u {
648+
if str::len_bytes(curr_line) != 0u {
649649
trim_whitespace_prefix_and_push_line(lines, curr_line, col);
650650
}
651651
let style = if code_to_the_left { trailing } else { isolated };

src/comp/syntax/print/pp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ fn end(p: printer) { p.pretty_print(END); }
491491
fn eof(p: printer) { p.pretty_print(EOF); }
492492

493493
fn word(p: printer, wrd: str) {
494-
p.pretty_print(STRING(wrd, str::char_len(wrd) as int));
494+
p.pretty_print(STRING(wrd, str::len(wrd) as int));
495495
}
496496

497497
fn huge_word(p: printer, wrd: str) {

src/comp/syntax/print/pprust.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ fn head(s: ps, w: str) {
201201
// outer-box is consistent
202202
cbox(s, indent_unit);
203203
// head-box is inconsistent
204-
ibox(s, str::char_len(w) + 1u);
204+
ibox(s, str::len(w) + 1u);
205205
// keyword that starts the head
206206
word_nbsp(s, w);
207207
}
@@ -1458,7 +1458,7 @@ fn print_ty_fn(s: ps, opt_proto: option<ast::proto>,
14581458
popen(s);
14591459
fn print_arg(s: ps, input: ast::arg) {
14601460
print_arg_mode(s, input.mode);
1461-
if str::byte_len(input.ident) > 0u {
1461+
if str::len_bytes(input.ident) > 0u {
14621462
word_space(s, input.ident + ":");
14631463
}
14641464
print_type(s, input.ty);
@@ -1640,7 +1640,7 @@ fn print_string(s: ps, st: str) {
16401640

16411641
fn escape_str(st: str, to_escape: char) -> str {
16421642
let out: str = "";
1643-
let len = str::byte_len(st);
1643+
let len = str::len_bytes(st);
16441644
let i = 0u;
16451645
while i < len {
16461646
alt st[i] as char {

src/comp/util/ppaux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
132132

133133
fn ty_to_short_str(cx: ctxt, typ: t) -> str unsafe {
134134
let s = encoder::encoded_ty(cx, typ);
135-
if str::byte_len(s) >= 32u { s = str::unsafe::slice_bytes(s, 0u, 32u); }
135+
if str::len_bytes(s) >= 32u { s = str::unsafe::slice_bytes(s, 0u, 32u); }
136136
ret s;
137137
}
138138

src/compiletest/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ fn parse_expected(line_num: uint, line: str) -> [expected_error] unsafe {
2626
let error_tag = "//!";
2727
let idx0 = str::find(line, error_tag);
2828
if idx0 < 0 { ret []; }
29-
let idx = (idx0 as uint) + str::byte_len(error_tag);
29+
let idx = (idx0 as uint) + str::len_bytes(error_tag);
3030

3131
// "//!^^^ kind msg" denotes a message expected
3232
// three lines above current line:
3333
let adjust_line = 0u;
34-
let len = str::byte_len(line);
34+
let len = str::len_bytes(line);
3535
while idx < len && line[idx] == ('^' as u8) {
3636
adjust_line += 1u;
3737
idx += 1u;

src/compiletest/header.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ fn parse_name_value_directive(line: str,
109109
if str::find(line, keycolon) >= 0 {
110110
let colon = str::find(line, keycolon) as uint;
111111
let value =
112-
str::unsafe::slice_bytes(line, colon + str::byte_len(keycolon),
113-
str::byte_len(line));
112+
str::unsafe::slice_bytes(line, colon + str::len_bytes(keycolon),
113+
str::len_bytes(line));
114114
#debug("%s: %s", directive, value);
115115
option::some(value)
116116
} else { option::none }

src/fuzzer/fuzzer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ fn check_variants_T<T: copy>(
285285

286286
fn last_part(filename: str) -> str {
287287
let ix = option::get(str::rindex(filename, '/'));
288-
str::slice(filename, ix + 1u, str::char_len(filename) - 3u)
288+
str::slice(filename, ix + 1u, str::len(filename) - 3u)
289289
}
290290

291291
enum happiness { passed, cleanly_rejected(str), known_bug(str), failed(str), }
@@ -333,7 +333,7 @@ fn removeDirIfExists(filename: str) {
333333
fn check_running(exe_filename: str) -> happiness {
334334
let p = std::run::program_output("/Users/jruderman/scripts/timed_run_rust_program.py", [exe_filename]);
335335
let comb = p.out + "\n" + p.err;
336-
if str::byte_len(comb) > 1u {
336+
if str::len_bytes(comb) > 1u {
337337
log(error, "comb comb comb: " + comb);
338338
}
339339

src/libcore/extfmt.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ mod ct {
8282

8383
fn parse_fmt_string(s: str, error: error_fn) -> [piece] unsafe {
8484
let pieces: [piece] = [];
85-
let lim = str::byte_len(s);
85+
let lim = str::len_bytes(s);
8686
let buf = "";
8787
fn flush_buf(buf: str, &pieces: [piece]) -> str {
88-
if str::byte_len(buf) > 0u {
88+
if str::len_bytes(buf) > 0u {
8989
let piece = piece_string(buf);
9090
pieces += [piece];
9191
}
@@ -325,7 +325,7 @@ mod rt {
325325
alt cv.precision {
326326
count_implied { s }
327327
count_is(max) {
328-
if max as uint < str::char_len(s) {
328+
if max as uint < str::len(s) {
329329
str::substr(s, 0u, max as uint)
330330
} else { s }
331331
}
@@ -368,7 +368,7 @@ mod rt {
368368
""
369369
} else {
370370
let s = uint::to_str(num, radix);
371-
let len = str::char_len(s);
371+
let len = str::len(s);
372372
if len < prec {
373373
let diff = prec - len;
374374
let pad = str_init_elt(diff, '0');
@@ -400,7 +400,7 @@ mod rt {
400400
uwidth = width as uint;
401401
}
402402
}
403-
let strlen = str::char_len(s);
403+
let strlen = str::len(s);
404404
if uwidth <= strlen { ret s; }
405405
let padchar = ' ';
406406
let diff = uwidth - strlen;
@@ -433,12 +433,12 @@ mod rt {
433433
// zeros. It may make sense to convert zero padding to a precision
434434
// instead.
435435

436-
if signed && zero_padding && str::byte_len(s) > 0u {
436+
if signed && zero_padding && str::len_bytes(s) > 0u {
437437
let head = s[0];
438438
if head == '+' as u8 || head == '-' as u8 || head == ' ' as u8 {
439439
let headstr = str::from_bytes([head]);
440440
// FIXME: not UTF-8 safe
441-
let bytelen = str::byte_len(s);
441+
let bytelen = str::len_bytes(s);
442442
let numpart = str::unsafe::slice_bytes(s, 1u, bytelen);
443443
ret headstr + padstr + numpart;
444444
}

src/libcore/float.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ fn from_str(num: str) -> float {
128128

129129
let pos = 0u; //Current byte position in the string.
130130
//Used to walk the string in O(n).
131-
let len = str::byte_len(num); //Length of the string, in bytes.
131+
let len = str::len_bytes(num); //Length of the string, in bytes.
132132

133133
if len == 0u { ret 0.; }
134134
let total = 0f; //Accumulated result

0 commit comments

Comments
 (0)