Skip to content

Commit 5412293

Browse files
committed
---
yaml --- r: 11212 b: refs/heads/master c: 27161f4 h: refs/heads/master v: v3
1 parent d29467d commit 5412293

File tree

6 files changed

+34
-35
lines changed

6 files changed

+34
-35
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 14baf88f89241f1384e4d12b4751910fe16c947c
2+
refs/heads/master: 27161f4415e484680cf404b9819bf37d66c26783
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/cargo/cargo.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -651,25 +651,27 @@ 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_byte(uuid, '/' as u8);
655-
if idx != -1 {
656-
let source = str::unsafe::slice_bytes(uuid, 0u, idx as uint);
657-
uuid = str::unsafe::slice_bytes(uuid, idx as uint + 1u,
658-
str::byte_len(uuid));
659-
install_uuid_specific(c, wd, source, uuid);
660-
} else {
661-
install_uuid(c, wd, uuid);
654+
alt str::index(uuid, '/') {
655+
option::some(idx) {
656+
let source = str::slice(uuid, 0u, idx);
657+
uuid = str::slice(uuid, idx + 1u, str::char_len(uuid));
658+
install_uuid_specific(c, wd, source, uuid);
659+
}
660+
option::none {
661+
install_uuid(c, wd, uuid);
662+
}
662663
}
663664
} else {
664665
let name = target;
665-
let idx = str::index_byte(name, '/' as u8);
666-
if idx != -1 {
667-
let source = str::unsafe::slice_bytes(name, 0u, idx as uint);
668-
name = str::unsafe::slice_bytes(name, idx as uint + 1u,
669-
str::byte_len(name));
670-
install_named_specific(c, wd, source, name);
671-
} else {
672-
install_named(c, wd, name);
666+
alt str::index(name, '/') {
667+
option::some(idx) {
668+
let source = str::slice(name, 0u, idx);
669+
name = str::slice(name, idx + 1u, str::char_len(name));
670+
install_named_specific(c, wd, source, name);
671+
}
672+
option::none {
673+
install_named(c, wd, name);
674+
}
673675
}
674676
}
675677
}

trunk/src/comp/back/link.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,16 @@ 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_byte(output_path, '.' as u8);
113-
let stem;
114-
if dot_pos < 0 {
115-
stem = output_path;
116-
} else { stem = str::unsafe::slice_bytes(output_path, 0u,
117-
dot_pos as uint); }
112+
let stem = alt str::index(output_path, '.') {
113+
option::some(dot_pos) {
114+
str::slice(output_path, 0u, dot_pos)
115+
}
116+
option::none { output_path }
117+
};
118+
118119
ret stem + "." + extension;
119120
}
121+
120122
fn run_passes(sess: session, llmod: ModuleRef, output: str) {
121123
let opts = sess.opts;
122124
if opts.time_llvm_passes { llvm::LLVMRustEnableTimePasses(); }

trunk/src/comp/syntax/codemap.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,13 @@ fn get_line(fm: filemap, line: int) -> str unsafe {
119119
let end: uint;
120120
if line as uint < vec::len(fm.lines) - 1u {
121121
end = fm.lines[line + 1].byte - fm.start_pos.byte;
122+
ret str::unsafe::slice_bytes(*fm.src, begin, end);
122123
} else {
123124
// If we're not done parsing the file, we're at the limit of what's
124125
// parsed. If we just slice the rest of the string, we'll print out
125126
// the remainder of the file, which is undesirable.
126-
end = str::byte_len(*fm.src);
127-
let rest = str::unsafe::slice_bytes(*fm.src, begin, end);
128-
let newline = str::index_byte(rest, '\n' as u8);
129-
if newline != -1 { end = begin + (newline as uint); }
127+
ret str::splitn_char(*fm.src, '\n', 1u)[0];
130128
}
131-
ret str::unsafe::slice_bytes(*fm.src, begin, end);
132129
}
133130

134131
fn lookup_byte_offset(cm: codemap::codemap, chpos: uint)

trunk/src/libcore/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export
7070
lines_iter,
7171

7272
// Searching
73-
//index,
73+
index,
7474
//rindex,
7575
index_byte,
7676
rindex_byte,

trunk/src/libstd/getopts.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,14 @@ 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_byte(tail, '=' as u8);
234-
if eq == -1 {
233+
let tail_eq = str::splitn_char(tail, '=', 1u);
234+
if vec::len(tail_eq) <= 1u {
235235
names = [long(tail)];
236236
} else {
237237
names =
238-
[long(str::unsafe::slice_bytes(tail,0u,eq as uint))];
238+
[long(tail_eq[0])];
239239
i_arg =
240-
option::some::<str>(str::unsafe::slice_bytes(tail,
241-
(eq as uint) + 1u,
242-
curlen - 2u));
240+
option::some::<str>(tail_eq[1]);
243241
}
244242
} else {
245243
let j = 1u;

0 commit comments

Comments
 (0)