(core::str) replace byte_index[_from] with index[_from]
This commit is contained in:
parent
280633a728
commit
6ea3d7935e
@ -174,10 +174,10 @@ fn print(s: str) {
|
||||
}
|
||||
|
||||
fn rest(s: str, start: uint) -> str {
|
||||
if (start >= str::len_chars(s)) {
|
||||
if (start >= str::len_bytes(s)) {
|
||||
""
|
||||
} else {
|
||||
str::slice_chars(s, start, str::len_chars(s))
|
||||
str::slice(s, start, str::len_bytes(s))
|
||||
}
|
||||
}
|
||||
|
||||
@ -686,10 +686,10 @@ fn cmd_install(c: cargo) unsafe {
|
||||
|
||||
if str::starts_with(target, "uuid:") {
|
||||
let uuid = rest(target, 5u);
|
||||
alt str::index_chars(uuid, '/') {
|
||||
alt str::index(uuid, '/') {
|
||||
option::some(idx) {
|
||||
let source = str::slice_chars(uuid, 0u, idx);
|
||||
uuid = str::slice_chars(uuid, idx + 1u, str::len_chars(uuid));
|
||||
let source = str::slice(uuid, 0u, idx);
|
||||
uuid = str::slice(uuid, idx + 1u, str::len_bytes(uuid));
|
||||
install_uuid_specific(c, wd, source, uuid);
|
||||
}
|
||||
option::none {
|
||||
@ -698,10 +698,10 @@ fn cmd_install(c: cargo) unsafe {
|
||||
}
|
||||
} else {
|
||||
let name = target;
|
||||
alt str::index_chars(name, '/') {
|
||||
alt str::index(name, '/') {
|
||||
option::some(idx) {
|
||||
let source = str::slice_chars(name, 0u, idx);
|
||||
name = str::slice_chars(name, idx + 1u, str::len_chars(name));
|
||||
let source = str::slice(name, 0u, idx);
|
||||
name = str::slice(name, idx + 1u, str::len_bytes(name));
|
||||
install_named_specific(c, wd, source, name);
|
||||
}
|
||||
option::none {
|
||||
|
@ -157,7 +157,7 @@ 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::byte_index_from(*fm.src, '\n' as u8, begin,
|
||||
let end = alt str::index_from(*fm.src, '\n', begin,
|
||||
str::len_bytes(*fm.src)) {
|
||||
some(e) { e }
|
||||
none { str::len_bytes(*fm.src) }
|
||||
|
@ -71,8 +71,10 @@ export
|
||||
|
||||
// Searching
|
||||
index_chars,
|
||||
byte_index,
|
||||
byte_index_from,
|
||||
index,
|
||||
index_from,
|
||||
//byte_index,
|
||||
//byte_index_from,
|
||||
rindex,
|
||||
//rindex_chars,
|
||||
find_chars,
|
||||
|
@ -70,8 +70,8 @@ fn to_str(j: json) -> str {
|
||||
}
|
||||
|
||||
fn rest(s: str) -> str {
|
||||
assert(str::len_chars(s) >= 1u);
|
||||
str::slice_chars(s, 1u, str::len_chars(s))
|
||||
assert(str::len_bytes(s) >= 1u);
|
||||
str::slice(s, 1u, str::len_bytes(s))
|
||||
}
|
||||
|
||||
fn from_str_str(s: str) -> (option<json>, str) {
|
||||
@ -99,7 +99,7 @@ fn from_str_str(s: str) -> (option<json>, str) {
|
||||
cont;
|
||||
} else if (c == '"') {
|
||||
ret (some(string(res)),
|
||||
str::slice_chars(s, pos, str::len_chars(s)));
|
||||
str::slice(s, pos, str::len_bytes(s)));
|
||||
}
|
||||
res = res + str::from_char(c);
|
||||
}
|
||||
@ -200,13 +200,13 @@ fn from_str_float(s: str) -> (option<json>, str) {
|
||||
}
|
||||
'.' { break; }
|
||||
_ { ret (some(num(neg * res)),
|
||||
str::slice_chars(s, opos, str::len_chars(s))); }
|
||||
str::slice(s, opos, str::len_bytes(s))); }
|
||||
}
|
||||
}
|
||||
|
||||
if pos == len {
|
||||
ret (some(num(neg * res)),
|
||||
str::slice_chars(s, pos, str::len_chars(s)));
|
||||
str::slice(s, pos, str::len_bytes(s)));
|
||||
}
|
||||
|
||||
let dec = 1f;
|
||||
@ -221,17 +221,17 @@ fn from_str_float(s: str) -> (option<json>, str) {
|
||||
res += (((c as int) - ('0' as int)) as float) * dec;
|
||||
}
|
||||
_ { ret (some(num(neg * res)),
|
||||
str::slice_chars(s, opos, str::len_chars(s))); }
|
||||
str::slice(s, opos, str::len_bytes(s))); }
|
||||
}
|
||||
}
|
||||
ret (some(num(neg * res)), str::slice_chars(s, pos, str::len_chars(s)));
|
||||
ret (some(num(neg * res)), str::slice(s, pos, str::len_bytes(s)));
|
||||
}
|
||||
|
||||
fn from_str_bool(s: str) -> (option<json>, str) {
|
||||
if (str::starts_with(s, "true")) {
|
||||
(some(boolean(true)), str::slice_chars(s, 4u, str::len_chars(s)))
|
||||
(some(boolean(true)), str::slice(s, 4u, str::len_bytes(s)))
|
||||
} else if (str::starts_with(s, "false")) {
|
||||
(some(boolean(false)), str::slice_chars(s, 5u, str::len_chars(s)))
|
||||
(some(boolean(false)), str::slice(s, 5u, str::len_bytes(s)))
|
||||
} else {
|
||||
(none, s)
|
||||
}
|
||||
@ -239,7 +239,7 @@ fn from_str_bool(s: str) -> (option<json>, str) {
|
||||
|
||||
fn from_str_null(s: str) -> (option<json>, str) {
|
||||
if (str::starts_with(s, "null")) {
|
||||
(some(null), str::slice_chars(s, 4u, str::len_chars(s)))
|
||||
(some(null), str::slice(s, 4u, str::len_bytes(s)))
|
||||
} else {
|
||||
(none, s)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user