Skip to content

Commit a131b43

Browse files
committed
core::str rename [r]index -> [r]index_bytes
1 parent 4339307 commit a131b43

File tree

7 files changed

+22
-20
lines changed

7 files changed

+22
-20
lines changed

src/cargo/cargo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ fn cmd_install(c: cargo) unsafe {
651651

652652
if str::starts_with(target, "uuid:") {
653653
let uuid = rest(target, 5u);
654-
let idx = str::index(uuid, '/' as u8);
654+
let idx = str::index_byte(uuid, '/' as u8);
655655
if idx != -1 {
656656
let source = str::unsafe::slice_bytes(uuid, 0u, idx as uint);
657657
uuid = str::unsafe::slice_bytes(uuid, idx as uint + 1u,
@@ -662,7 +662,7 @@ fn cmd_install(c: cargo) unsafe {
662662
}
663663
} else {
664664
let name = target;
665-
let idx = str::index(name, '/' as u8);
665+
let idx = str::index_byte(name, '/' as u8);
666666
if idx != -1 {
667667
let source = str::unsafe::slice_bytes(name, 0u, idx as uint);
668668
name = str::unsafe::slice_bytes(name, idx as uint + 1u,

src/comp/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ mod write {
109109
// Decides what to call an intermediate file, given the name of the output
110110
// and the extension to use.
111111
fn mk_intermediate_name(output_path: str, extension: str) -> str unsafe {
112-
let dot_pos = str::index(output_path, '.' as u8);
112+
let dot_pos = str::index_byte(output_path, '.' as u8);
113113
let stem;
114114
if dot_pos < 0 {
115115
stem = output_path;

src/comp/syntax/codemap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ fn get_line(fm: filemap, line: int) -> str unsafe {
125125
// the remainder of the file, which is undesirable.
126126
end = str::byte_len(*fm.src);
127127
let rest = str::unsafe::slice_bytes(*fm.src, begin, end);
128-
let newline = str::index(rest, '\n' as u8);
128+
let newline = str::index_byte(rest, '\n' as u8);
129129
if newline != -1 { end = begin + (newline as uint); }
130130
}
131131
ret str::unsafe::slice_bytes(*fm.src, begin, end);

src/fuzzer/fuzzer.rs

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

286286
fn last_part(filename: str) -> str unsafe {
287-
let ix = str::rindex(filename, 47u8 /* '/' */);
287+
let ix = str::rindex_byte(filename, 47u8 /* '/' */);
288288
assert ix >= 0;
289289
str::unsafe::slice_bytes(filename, ix as uint + 1u, str::byte_len(filename) - 3u)
290290
}

src/libcore/str.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ export
7070
lines_iter,
7171

7272
// Searching
73-
index,
74-
rindex,
73+
//index,
74+
//rindex,
75+
index_byte,
76+
rindex_byte,
7577
find,
7678
contains,
7779
starts_with,
@@ -876,7 +878,7 @@ no match is found.
876878
877879
FIXME: UTF-8
878880
*/
879-
fn index(s: str, c: u8) -> int {
881+
fn index_byte(s: str, c: u8) -> int {
880882
let i: int = 0;
881883
for k: u8 in s { if k == c { ret i; } i += 1; }
882884
ret -1;
@@ -890,7 +892,7 @@ if no match is found.
890892
891893
FIXME: UTF-8
892894
*/
893-
fn rindex(s: str, c: u8) -> int {
895+
fn rindex_byte(s: str, c: u8) -> int {
894896
let n: int = byte_len(s) as int;
895897
while n >= 0 { if s[n] == c { ret n; } n -= 1; }
896898
ret n;
@@ -1443,12 +1445,12 @@ mod tests {
14431445

14441446
#[test]
14451447
fn test_index_and_rindex() {
1446-
assert (index("hello", 'e' as u8) == 1);
1447-
assert (index("hello", 'o' as u8) == 4);
1448-
assert (index("hello", 'z' as u8) == -1);
1449-
assert (rindex("hello", 'l' as u8) == 3);
1450-
assert (rindex("hello", 'h' as u8) == 0);
1451-
assert (rindex("hello", 'z' as u8) == -1);
1448+
assert (index_byte("hello", 'e' as u8) == 1);
1449+
assert (index_byte("hello", 'o' as u8) == 4);
1450+
assert (index_byte("hello", 'z' as u8) == -1);
1451+
assert (rindex_byte("hello", 'l' as u8) == 3);
1452+
assert (rindex_byte("hello", 'h' as u8) == 0);
1453+
assert (rindex_byte("hello", 'z' as u8) == -1);
14521454
}
14531455

14541456
#[test]

src/libstd/fs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ The dirname of "/usr/share" will be "/usr", but the dirname of
4444
If the path is not prefixed with a directory, then "." is returned.
4545
*/
4646
fn dirname(p: path) -> path unsafe {
47-
let i: int = str::rindex(p, os_fs::path_sep as u8);
47+
let i: int = str::rindex_byte(p, os_fs::path_sep as u8);
4848
if i == -1 {
49-
i = str::rindex(p, os_fs::alt_path_sep as u8);
49+
i = str::rindex_byte(p, os_fs::alt_path_sep as u8);
5050
if i == -1 { ret "."; }
5151
}
5252
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
6464
with a path separator then an empty path is returned.
6565
*/
6666
fn basename(p: path) -> path unsafe {
67-
let i: int = str::rindex(p, os_fs::path_sep as u8);
67+
let i: int = str::rindex_byte(p, os_fs::path_sep as u8);
6868
if i == -1 {
69-
i = str::rindex(p, os_fs::alt_path_sep as u8);
69+
i = str::rindex_byte(p, os_fs::alt_path_sep as u8);
7070
if i == -1 { ret p; }
7171
}
7272
let len = str::byte_len(p);

src/libstd/getopts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ fn getopts(args: [str], opts: [opt]) -> result unsafe {
230230
let i_arg = option::none::<str>;
231231
if cur[1] == '-' as u8 {
232232
let tail = str::unsafe::slice_bytes(cur, 2u, curlen);
233-
let eq = str::index(tail, '=' as u8);
233+
let eq = str::index_byte(tail, '=' as u8);
234234
if eq == -1 {
235235
names = [long(tail)];
236236
} else {

0 commit comments

Comments
 (0)