Skip to content

Commit 6ea3d79

Browse files
killerswanmarijnh
authored andcommitted
(core::str) replace byte_index[_from] with index[_from]
1 parent 280633a commit 6ea3d79

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

src/cargo/cargo.rs

Lines changed: 8 additions & 8 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_chars(s)) {
177+
if (start >= str::len_bytes(s)) {
178178
""
179179
} else {
180-
str::slice_chars(s, start, str::len_chars(s))
180+
str::slice(s, start, str::len_bytes(s))
181181
}
182182
}
183183

@@ -686,10 +686,10 @@ fn cmd_install(c: cargo) unsafe {
686686

687687
if str::starts_with(target, "uuid:") {
688688
let uuid = rest(target, 5u);
689-
alt str::index_chars(uuid, '/') {
689+
alt str::index(uuid, '/') {
690690
option::some(idx) {
691-
let source = str::slice_chars(uuid, 0u, idx);
692-
uuid = str::slice_chars(uuid, idx + 1u, str::len_chars(uuid));
691+
let source = str::slice(uuid, 0u, idx);
692+
uuid = str::slice(uuid, idx + 1u, str::len_bytes(uuid));
693693
install_uuid_specific(c, wd, source, uuid);
694694
}
695695
option::none {
@@ -698,10 +698,10 @@ fn cmd_install(c: cargo) unsafe {
698698
}
699699
} else {
700700
let name = target;
701-
alt str::index_chars(name, '/') {
701+
alt str::index(name, '/') {
702702
option::some(idx) {
703-
let source = str::slice_chars(name, 0u, idx);
704-
name = str::slice_chars(name, idx + 1u, str::len_chars(name));
703+
let source = str::slice(name, 0u, idx);
704+
name = str::slice(name, idx + 1u, str::len_bytes(name));
705705
install_named_specific(c, wd, source, name);
706706
}
707707
option::none {

src/comp/syntax/codemap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines {
157157

158158
fn get_line(fm: filemap, line: int) -> str unsafe {
159159
let begin: uint = fm.lines[line].byte - fm.start_pos.byte;
160-
let end = alt str::byte_index_from(*fm.src, '\n' as u8, begin,
160+
let end = alt str::index_from(*fm.src, '\n', begin,
161161
str::len_bytes(*fm.src)) {
162162
some(e) { e }
163163
none { str::len_bytes(*fm.src) }

src/libcore/str.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ export
7171

7272
// Searching
7373
index_chars,
74-
byte_index,
75-
byte_index_from,
74+
index,
75+
index_from,
76+
//byte_index,
77+
//byte_index_from,
7678
rindex,
7779
//rindex_chars,
7880
find_chars,

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_chars(s) >= 1u);
74-
str::slice_chars(s, 1u, str::len_chars(s))
73+
assert(str::len_bytes(s) >= 1u);
74+
str::slice(s, 1u, str::len_bytes(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_chars(s, pos, str::len_chars(s)));
102+
str::slice(s, pos, str::len_bytes(s)));
103103
}
104104
res = res + str::from_char(c);
105105
}
@@ -200,13 +200,13 @@ fn from_str_float(s: str) -> (option<json>, str) {
200200
}
201201
'.' { break; }
202202
_ { ret (some(num(neg * res)),
203-
str::slice_chars(s, opos, str::len_chars(s))); }
203+
str::slice(s, opos, str::len_bytes(s))); }
204204
}
205205
}
206206

207207
if pos == len {
208208
ret (some(num(neg * res)),
209-
str::slice_chars(s, pos, str::len_chars(s)));
209+
str::slice(s, pos, str::len_bytes(s)));
210210
}
211211

212212
let dec = 1f;
@@ -221,25 +221,25 @@ fn from_str_float(s: str) -> (option<json>, str) {
221221
res += (((c as int) - ('0' as int)) as float) * dec;
222222
}
223223
_ { ret (some(num(neg * res)),
224-
str::slice_chars(s, opos, str::len_chars(s))); }
224+
str::slice(s, opos, str::len_bytes(s))); }
225225
}
226226
}
227-
ret (some(num(neg * res)), str::slice_chars(s, pos, str::len_chars(s)));
227+
ret (some(num(neg * res)), str::slice(s, pos, str::len_bytes(s)));
228228
}
229229

230230
fn from_str_bool(s: str) -> (option<json>, str) {
231231
if (str::starts_with(s, "true")) {
232-
(some(boolean(true)), str::slice_chars(s, 4u, str::len_chars(s)))
232+
(some(boolean(true)), str::slice(s, 4u, str::len_bytes(s)))
233233
} else if (str::starts_with(s, "false")) {
234-
(some(boolean(false)), str::slice_chars(s, 5u, str::len_chars(s)))
234+
(some(boolean(false)), str::slice(s, 5u, str::len_bytes(s)))
235235
} else {
236236
(none, s)
237237
}
238238
}
239239

240240
fn from_str_null(s: str) -> (option<json>, str) {
241241
if (str::starts_with(s, "null")) {
242-
(some(null), str::slice_chars(s, 4u, str::len_chars(s)))
242+
(some(null), str::slice(s, 4u, str::len_bytes(s)))
243243
} else {
244244
(none, s)
245245
}

0 commit comments

Comments
 (0)