Skip to content

Commit e127bf6

Browse files
kevinagraydon
authored andcommitted
Fix byte_len in char_len_range to be what it is advertised.
1 parent 33f4a98 commit e127bf6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/libcore/str.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,15 +1066,15 @@ Safety note:
10661066
FIXME: rename to 'substr_len_chars'
10671067
*/
10681068
fn char_len_range(s: str, byte_start: uint, byte_len: uint) -> uint {
1069-
let i = byte_start;
1069+
let i = byte_start;
1070+
let byte_stop = i + byte_len;
10701071
let len = 0u;
1071-
while i < byte_len {
1072+
while i < byte_stop {
10721073
let chsize = utf8_char_width(s[i]);
10731074
assert (chsize > 0u);
10741075
len += 1u;
10751076
i += chsize;
10761077
}
1077-
assert (i == byte_len);
10781078
ret len;
10791079
}
10801080

0 commit comments

Comments
 (0)