Skip to content

Commit 5f1242e

Browse files
killerswanmarijnh
authored andcommitted
---
yaml --- r: 14435 b: refs/heads/try c: 98447f5 h: refs/heads/master i: 14433: a78362b 14431: de65559 v: v3
1 parent ecd9eb8 commit 5f1242e

File tree

18 files changed

+55
-53
lines changed

18 files changed

+55
-53
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 7a6498668f2f4d3eff393809418b565d027b35bd
5+
refs/heads/try: 98447f523603ce8ca5a258f216f6fcbd90fe114f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/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::len(s)) {
177+
if (start >= str::len_chars(s)) {
178178
""
179179
} else {
180-
str::slice(s, start, str::len(s))
180+
str::slice(s, start, str::len_chars(s))
181181
}
182182
}
183183

@@ -689,7 +689,7 @@ fn cmd_install(c: cargo) unsafe {
689689
alt str::index(uuid, '/') {
690690
option::some(idx) {
691691
let source = str::slice(uuid, 0u, idx);
692-
uuid = str::slice(uuid, idx + 1u, str::len(uuid));
692+
uuid = str::slice(uuid, idx + 1u, str::len_chars(uuid));
693693
install_uuid_specific(c, wd, source, uuid);
694694
}
695695
option::none {
@@ -701,7 +701,7 @@ fn cmd_install(c: cargo) unsafe {
701701
alt str::index(name, '/') {
702702
option::some(idx) {
703703
let source = str::slice(name, 0u, idx);
704-
name = str::slice(name, idx + 1u, str::len(name));
704+
name = str::slice(name, idx + 1u, str::len_chars(name));
705705
install_named_specific(c, wd, source, name);
706706
}
707707
option::none {

branches/try/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::len(s);
213+
let indent = str::len_bytes(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::len(fm.name) + digits + lo.col + 3u;
231+
let left = str::len_bytes(fm.name) + digits + lo.col + 3u;
232232
let s = "";
233233
while left > 0u { str::push_char(s, ' '); left -= 1u; }
234234

branches/try/src/comp/syntax/codemap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines {
158158
fn get_line(fm: filemap, line: int) -> str unsafe {
159159
let begin: uint = fm.lines[line].byte - fm.start_pos.byte;
160160
let end = alt str::byte_index_from(*fm.src, '\n' as u8, begin,
161-
str::len(*fm.src)) {
161+
str::len_bytes(*fm.src)) {
162162
some(e) { e }
163-
none { str::len(*fm.src) }
163+
none { str::len_bytes(*fm.src) }
164164
};
165165
str::unsafe::slice_bytes(*fm.src, begin, end)
166166
}

branches/try/src/comp/syntax/ext/qquote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ fn finish<T: qq_helper>
214214
if (j < g_len && i == cx.gather[j].lo) {
215215
assert ch == '$';
216216
let repl = #fmt("$%u ", j);
217-
state = skip(str::len(repl));
217+
state = skip(str::len_chars(repl));
218218
str2 += repl;
219219
}
220220
alt state {

branches/try/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::len(wrd) as int));
494+
p.pretty_print(STRING(wrd, str::len_bytes(wrd) as int));
495495
}
496496

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

branches/try/src/comp/syntax/print/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ fn head(s: ps, w: str) {
204204
// outer-box is consistent
205205
cbox(s, indent_unit);
206206
// head-box is inconsistent
207-
ibox(s, str::len(w) + 1u);
207+
ibox(s, str::len_bytes(w) + 1u);
208208
// keyword that starts the head
209209
word_nbsp(s, w);
210210
}

branches/try/src/fuzzer/fuzzer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ fn check_variants_T<T: copy>(
287287

288288
fn last_part(filename: str) -> str {
289289
let ix = option::get(str::rindex(filename, '/'));
290-
str::slice(filename, ix + 1u, str::len(filename) - 3u)
290+
str::slice(filename, ix + 1u, str::len_chars(filename) - 3u)
291291
}
292292

293293
enum happiness { passed, cleanly_rejected(str), known_bug(str), failed(str), }

branches/try/src/libcore/extfmt.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ mod rt {
325325
alt cv.precision {
326326
count_implied { s }
327327
count_is(max) {
328-
if max as uint < str::len(s) {
328+
if max as uint < str::len_chars(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::len(s);
371+
let len = str::len_chars(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::len(s);
403+
let strlen = str::len_chars(s);
404404
if uwidth <= strlen { ret s; }
405405
let padchar = ' ';
406406
let diff = uwidth - strlen;

branches/try/src/libcore/str.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export
8686
is_not_empty,
8787
is_whitespace,
8888
len_bytes,
89-
len_chars, len,
89+
len_chars, //len,
9090

9191
// Misc
9292
// FIXME: perhaps some more of this section shouldn't be exported?
@@ -529,7 +529,7 @@ fn split(ss: str, sepfn: fn(cc: char)->bool) -> [str] {
529529
}
530530
});
531531

532-
if len(accum) >= 0u || ends_with_sep {
532+
if len_chars(accum) >= 0u || ends_with_sep {
533533
vv += [accum];
534534
}
535535

@@ -601,7 +601,7 @@ separated by whitespace
601601
*/
602602
fn words(ss: str) -> [str] {
603603
ret vec::filter( split(ss, {|cc| char::is_whitespace(cc)}),
604-
{|w| 0u < str::len(w)});
604+
{|w| 0u < str::len_chars(w)});
605605
}
606606

607607
/*
@@ -611,7 +611,7 @@ Create a vector of substrings of size `nn`
611611
*/
612612
fn windowed(nn: uint, ss: str) -> [str] {
613613
let ww = [];
614-
let len = str::len(ss);
614+
let len = str::len_chars(ss);
615615

616616
assert 1u <= nn;
617617

@@ -883,7 +883,7 @@ fn byte_index_from(s: str, b: u8, start: uint, end: uint) -> option<uint> {
883883
// (as option some/none)
884884
fn rindex(ss: str, cc: char) -> option<uint> {
885885
let bii = len_bytes(ss);
886-
let cii = len(ss);
886+
let cii = len_chars(ss);
887887
while bii > 0u {
888888
let {ch, prev} = char_range_at_reverse(ss, bii);
889889
cii -= 1u;
@@ -1008,8 +1008,8 @@ haystack - The string to look in
10081008
needle - The string to look for
10091009
*/
10101010
fn ends_with(haystack: str, needle: str) -> bool {
1011-
let haystack_len: uint = len(haystack);
1012-
let needle_len: uint = len(needle);
1011+
let haystack_len: uint = len_chars(haystack);
1012+
let needle_len: uint = len_chars(needle);
10131013
ret if needle_len == 0u {
10141014
true
10151015
} else if needle_len > haystack_len {
@@ -1079,7 +1079,9 @@ fn len(s: str) -> uint {
10791079
substr_len_chars(s, 0u, len_bytes(s))
10801080
}
10811081

1082-
fn len_chars(s: str) -> uint { len(s) }
1082+
fn len_chars(s: str) -> uint {
1083+
substr_len_chars(s, 0u, len_bytes(s))
1084+
}
10831085

10841086
/*
10851087
Section: Misc
@@ -1529,14 +1531,14 @@ mod tests {
15291531
assert (len_bytes("\u2620") == 3u);
15301532
assert (len_bytes("\U0001d11e") == 4u);
15311533

1532-
assert (len("") == 0u);
1533-
assert (len("hello world") == 11u);
1534-
assert (len("\x63") == 1u);
1535-
assert (len("\xa2") == 1u);
1536-
assert (len("\u03c0") == 1u);
1537-
assert (len("\u2620") == 1u);
1538-
assert (len("\U0001d11e") == 1u);
1539-
assert (len("ประเทศไทย中华Việt Nam") == 19u);
1534+
assert (len_chars("") == 0u);
1535+
assert (len_chars("hello world") == 11u);
1536+
assert (len_chars("\x63") == 1u);
1537+
assert (len_chars("\xa2") == 1u);
1538+
assert (len_chars("\u03c0") == 1u);
1539+
assert (len_chars("\u2620") == 1u);
1540+
assert (len_chars("\U0001d11e") == 1u);
1541+
assert (len_chars("ประเทศไทย中华Việt Nam") == 19u);
15401542
}
15411543

15421544
#[test]

branches/try/src/libstd/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn splitDirnameBasename (pp: path) -> {dirname: str, basename: str} {
4545
}
4646

4747
ret {dirname: str::slice(pp, 0u, ii),
48-
basename: str::slice(pp, ii + 1u, str::len(pp))};
48+
basename: str::slice(pp, ii + 1u, str::len_chars(pp))};
4949
}
5050

5151
/*

branches/try/src/libstd/getopts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ A description of a possible option
7979
type opt = {name: name, hasarg: hasarg, occur: occur};
8080

8181
fn mkname(nm: str) -> name {
82-
ret if str::len(nm) == 1u {
82+
ret if str::len_bytes(nm) == 1u {
8383
short(str::char_at(nm, 0u))
8484
} else { long(nm) };
8585
}

branches/try/src/libstd/json.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ fn to_str(j: json) -> str {
7070
}
7171

7272
fn rest(s: str) -> str {
73-
assert(str::len(s) >= 1u);
74-
str::slice(s, 1u, str::len(s))
73+
assert(str::len_chars(s) >= 1u);
74+
str::slice(s, 1u, str::len_chars(s))
7575
}
7676

7777
fn from_str_str(s: str) -> (option<json>, str) {
@@ -99,7 +99,7 @@ fn from_str_str(s: str) -> (option<json>, str) {
9999
cont;
100100
} else if (c == '"') {
101101
ret (some(string(res)),
102-
str::slice(s, pos, str::len(s)));
102+
str::slice(s, pos, str::len_chars(s)));
103103
}
104104
res = res + str::from_char(c);
105105
}
@@ -200,12 +200,12 @@ fn from_str_float(s: str) -> (option<json>, str) {
200200
}
201201
'.' { break; }
202202
_ { ret (some(num(neg * res)),
203-
str::slice(s, opos, str::len(s))); }
203+
str::slice(s, opos, str::len_chars(s))); }
204204
}
205205
}
206206

207207
if pos == len {
208-
ret (some(num(neg * res)), str::slice(s, pos, str::len(s)));
208+
ret (some(num(neg * res)), str::slice(s, pos, str::len_chars(s)));
209209
}
210210

211211
let dec = 1f;
@@ -220,25 +220,25 @@ fn from_str_float(s: str) -> (option<json>, str) {
220220
res += (((c as int) - ('0' as int)) as float) * dec;
221221
}
222222
_ { ret (some(num(neg * res)),
223-
str::slice(s, opos, str::len(s))); }
223+
str::slice(s, opos, str::len_chars(s))); }
224224
}
225225
}
226-
ret (some(num(neg * res)), str::slice(s, pos, str::len(s)));
226+
ret (some(num(neg * res)), str::slice(s, pos, str::len_chars(s)));
227227
}
228228

229229
fn from_str_bool(s: str) -> (option<json>, str) {
230230
if (str::starts_with(s, "true")) {
231-
(some(boolean(true)), str::slice(s, 4u, str::len(s)))
231+
(some(boolean(true)), str::slice(s, 4u, str::len_chars(s)))
232232
} else if (str::starts_with(s, "false")) {
233-
(some(boolean(false)), str::slice(s, 5u, str::len(s)))
233+
(some(boolean(false)), str::slice(s, 5u, str::len_chars(s)))
234234
} else {
235235
(none, s)
236236
}
237237
}
238238

239239
fn from_str_null(s: str) -> (option<json>, str) {
240240
if (str::starts_with(s, "null")) {
241-
(some(null), str::slice(s, 4u, str::len(s)))
241+
(some(null), str::slice(s, 4u, str::len_chars(s)))
242242
} else {
243243
(none, s)
244244
}

branches/try/src/libstd/rand.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn mk_rng() -> rng {
7777
let i = 0u;
7878
while (i < len) {
7979
let n = rustrt::rand_next(**self) as uint %
80-
str::len(charset);
80+
str::len_bytes(charset);
8181
s = s + str::from_char(str::char_at(charset, n));
8282
i += 1u;
8383
}
@@ -130,8 +130,8 @@ mod tests {
130130
log(debug, r.gen_str(10u));
131131
log(debug, r.gen_str(10u));
132132
log(debug, r.gen_str(10u));
133-
assert(str::len(r.gen_str(10u)) == 10u);
134-
assert(str::len(r.gen_str(16u)) == 16u);
133+
assert(str::len_bytes(r.gen_str(10u)) == 10u);
134+
assert(str::len_bytes(r.gen_str(16u)) == 16u);
135135
}
136136
}
137137

branches/try/src/libstd/rope.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ mod tests {
13731373
let sample = @"0123456789ABCDE";
13741374
let r = of_str(sample);
13751375

1376-
assert char_len(r) == str::len(*sample);
1376+
assert char_len(r) == str::len_chars(*sample);
13771377
assert rope_to_string(r) == *sample;
13781378
}
13791379

@@ -1384,7 +1384,7 @@ mod tests {
13841384
while i < 10 { *buf = *buf + *buf; i+=1;}
13851385
let sample = @*buf;
13861386
let r = of_str(sample);
1387-
assert char_len(r) == str::len(*sample);
1387+
assert char_len(r) == str::len_chars(*sample);
13881388
assert rope_to_string(r) == *sample;
13891389

13901390
let string_iter = 0u;
@@ -1427,7 +1427,7 @@ mod tests {
14271427
}
14281428
}
14291429

1430-
assert len == str::len(*sample);
1430+
assert len == str::len_chars(*sample);
14311431
}
14321432

14331433
#[test]

branches/try/src/rustdoc/desc_to_brief_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ fn parse_desc(desc: str) -> (option<str>, option<str>) {
175175

176176
if check vec::is_not_empty(paras) {
177177
let maybe_brief = vec::head(paras);
178-
if str::len(maybe_brief) <= max_brief_len {
178+
if str::len_bytes(maybe_brief) <= max_brief_len {
179179
let desc_paras = vec::tail(paras);
180180
let desc = if vec::is_not_empty(desc_paras) {
181181
some(str::connect(desc_paras, "\n\n"))

branches/try/src/rustdoc/unindent_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn unindent(s: str) -> str {
6868
line
6969
} else {
7070
assert str::len_bytes(line) >= min_indent;
71-
str::slice(line, min_indent, str::len(line))
71+
str::slice(line, min_indent, str::len_chars(line))
7272
}
7373
};
7474
str::connect(unindented, "\n")

branches/try/src/test/run-pass/utf8_chars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn main() {
88
let s: str = str::from_chars(chs);
99

1010
assert (str::len_bytes(s) == 10u);
11-
assert (str::len(s) == 4u);
11+
assert (str::len_chars(s) == 4u);
1212
assert (vec::len::<char>(str::chars(s)) == 4u);
1313
assert (str::eq(str::from_chars(str::chars(s)), s));
1414
assert (str::char_at(s, 0u) == 'e');

0 commit comments

Comments
 (0)