diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index 8536bf7d830a..aa042ea1ae46 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -651,7 +651,7 @@ fn cmd_install(c: cargo) unsafe { if str::starts_with(target, "uuid:") { let uuid = rest(target, 5u); - let idx = str::index(uuid, '/' as u8); + let idx = str::index_byte(uuid, '/' as u8); if idx != -1 { let source = str::unsafe::slice_bytes(uuid, 0u, idx as uint); uuid = str::unsafe::slice_bytes(uuid, idx as uint + 1u, @@ -662,7 +662,7 @@ fn cmd_install(c: cargo) unsafe { } } else { let name = target; - let idx = str::index(name, '/' as u8); + let idx = str::index_byte(name, '/' as u8); if idx != -1 { let source = str::unsafe::slice_bytes(name, 0u, idx as uint); name = str::unsafe::slice_bytes(name, idx as uint + 1u, diff --git a/src/comp/back/link.rs b/src/comp/back/link.rs index cb2070c124c5..4f32ad4a31fc 100644 --- a/src/comp/back/link.rs +++ b/src/comp/back/link.rs @@ -109,7 +109,7 @@ mod write { // Decides what to call an intermediate file, given the name of the output // and the extension to use. fn mk_intermediate_name(output_path: str, extension: str) -> str unsafe { - let dot_pos = str::index(output_path, '.' as u8); + let dot_pos = str::index_byte(output_path, '.' as u8); let stem; if dot_pos < 0 { stem = output_path; diff --git a/src/comp/syntax/codemap.rs b/src/comp/syntax/codemap.rs index 5d8d7ff56333..27f968b1156f 100644 --- a/src/comp/syntax/codemap.rs +++ b/src/comp/syntax/codemap.rs @@ -125,7 +125,7 @@ fn get_line(fm: filemap, line: int) -> str unsafe { // the remainder of the file, which is undesirable. end = str::byte_len(*fm.src); let rest = str::unsafe::slice_bytes(*fm.src, begin, end); - let newline = str::index(rest, '\n' as u8); + let newline = str::index_byte(rest, '\n' as u8); if newline != -1 { end = begin + (newline as uint); } } ret str::unsafe::slice_bytes(*fm.src, begin, end); diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index a5cfb8db3f7c..e3f452f68704 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -284,7 +284,7 @@ fn check_variants_T( } fn last_part(filename: str) -> str unsafe { - let ix = str::rindex(filename, 47u8 /* '/' */); + let ix = str::rindex_byte(filename, 47u8 /* '/' */); assert ix >= 0; str::unsafe::slice_bytes(filename, ix as uint + 1u, str::byte_len(filename) - 3u) } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index b98d96bb901a..bc96475990f9 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -70,8 +70,10 @@ export lines_iter, // Searching - index, - rindex, + //index, + //rindex, + index_byte, + rindex_byte, find, contains, starts_with, @@ -876,7 +878,7 @@ no match is found. FIXME: UTF-8 */ -fn index(s: str, c: u8) -> int { +fn index_byte(s: str, c: u8) -> int { let i: int = 0; for k: u8 in s { if k == c { ret i; } i += 1; } ret -1; @@ -890,7 +892,7 @@ if no match is found. FIXME: UTF-8 */ -fn rindex(s: str, c: u8) -> int { +fn rindex_byte(s: str, c: u8) -> int { let n: int = byte_len(s) as int; while n >= 0 { if s[n] == c { ret n; } n -= 1; } ret n; @@ -1443,12 +1445,12 @@ mod tests { #[test] fn test_index_and_rindex() { - assert (index("hello", 'e' as u8) == 1); - assert (index("hello", 'o' as u8) == 4); - assert (index("hello", 'z' as u8) == -1); - assert (rindex("hello", 'l' as u8) == 3); - assert (rindex("hello", 'h' as u8) == 0); - assert (rindex("hello", 'z' as u8) == -1); + assert (index_byte("hello", 'e' as u8) == 1); + assert (index_byte("hello", 'o' as u8) == 4); + assert (index_byte("hello", 'z' as u8) == -1); + assert (rindex_byte("hello", 'l' as u8) == 3); + assert (rindex_byte("hello", 'h' as u8) == 0); + assert (rindex_byte("hello", 'z' as u8) == -1); } #[test] diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 2304445b95b1..874d92cc4b9d 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -44,9 +44,9 @@ The dirname of "/usr/share" will be "/usr", but the dirname of If the path is not prefixed with a directory, then "." is returned. */ fn dirname(p: path) -> path unsafe { - let i: int = str::rindex(p, os_fs::path_sep as u8); + let i: int = str::rindex_byte(p, os_fs::path_sep as u8); if i == -1 { - i = str::rindex(p, os_fs::alt_path_sep as u8); + i = str::rindex_byte(p, os_fs::alt_path_sep as u8); if i == -1 { ret "."; } } ret str::unsafe::slice_bytes(p, 0u, i as uint); @@ -64,9 +64,9 @@ the provided path. If an empty path is provided or the path ends with a path separator then an empty path is returned. */ fn basename(p: path) -> path unsafe { - let i: int = str::rindex(p, os_fs::path_sep as u8); + let i: int = str::rindex_byte(p, os_fs::path_sep as u8); if i == -1 { - i = str::rindex(p, os_fs::alt_path_sep as u8); + i = str::rindex_byte(p, os_fs::alt_path_sep as u8); if i == -1 { ret p; } } let len = str::byte_len(p); diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 48d83f0e5c2c..33674fe67f38 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -230,7 +230,7 @@ fn getopts(args: [str], opts: [opt]) -> result unsafe { let i_arg = option::none::; if cur[1] == '-' as u8 { let tail = str::unsafe::slice_bytes(cur, 2u, curlen); - let eq = str::index(tail, '=' as u8); + let eq = str::index_byte(tail, '=' as u8); if eq == -1 { names = [long(tail)]; } else {